5

I am creating a winform apps in vs2019, create report via Report viewer and it's work well. However, when i embed the dll using Fody/Costura, somehow the report viewer give an error.

I also try manually embed the dll, but the same error still occur.

The error message appear in report viewer,

An error occured during local report processing. The definition of the report " is invalid. An unexpected error occured in Report Processing. The type initializer for "Microsoft.Reporting.Services.ReportIntermediateFormat.Persistence.IntermediateFormatVersion" threw an exception. The path is not a legal form.

Any help would be very appreciated. Thanks.

1 Answer 1

5

I encounter the same problem today. Base on the inner exception, it seems report viewer need to get the version of it's related dll to work correctly. If the dll is embeded, report viewer couldn't locate it.

System.ArgumentException: The path is not of a legal form.
   at System.IO.Path.NewNormalizePath(String path, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.NormalizePath(String path, Boolean fullCheck, Int32 maxPathLength, Boolean expandShortPaths)
   at System.IO.Path.GetFullPathInternal(String path)
   at System.IO.Path.GetFullPath(String path)
   at System.Diagnostics.FileVersionInfo.GetFullPathWithAssert(String fileName)
   at System.Diagnostics.FileVersionInfo.GetVersionInfo(String fileName)
   at Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.IntermediateFormatVersion.<>c__DisplayClass2_0.<.cctor>b__0()
   at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.<>c__DisplayClass1_0.<Run>b__0(Object state)
   at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
   at Microsoft.ReportingServices.Diagnostics.RevertImpersonationContext.Run(ContextBody callback)
   at Microsoft.ReportingServices.ReportIntermediateFormat.Persistence.IntermediateFormatVersion..cctor()
   --- End of inner exception stack trace ---

After some trial and error, I found that for report viewer working correctly, 'Microsoft.ReportViewer.ProcessingObjectModel' and 'Microsoft.ReportViewer.Common' need to be exclude from Fody/Costura. Following is the FodyWeavers.xml I'm using.

<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
  <Costura>
    <ExcludeAssemblies>
      Microsoft.ReportViewer.ProcessingObjectModel
      Microsoft.ReportViewer.Common
    </ExcludeAssemblies>
  </Costura>
</Weavers>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.