使用 costura 嵌入报表查看器 dll 时出错



我正在 vs2019 中创建 winform 应用程序,通过报告查看器创建报告,效果很好。但是,当我使用 Fody/Costura 嵌入 dll 时,不知何故报表查看器给出了错误。

我也尝试手动嵌入 dll,但仍然会出现相同的错误。

错误消息将显示在报表查看器中,

本地报表处理过程中出错。 报告的定义"无效。 报表处理中发生意外错误。 "Microsoft.Reporting.Services.ReportIntermediateFormat.Persistence.IntermediateFormatVersion"的类型初始值设定项引发了异常。 路径不是法律形式。

任何帮助将不胜感激。谢谢。

我今天遇到了同样的问题。基于内部异常,报表查看器似乎需要使其相关 dll 的版本正常工作。如果嵌入了 dll,则报表查看器找不到它。

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 ---

经过一些试验和错误,我发现要使报表查看器正常工作,需要从Fody/Costura中排除"Microsoft.ReportViewer.ProcessingObjectModel"和"Microsoft.ReportViewer.Common"。以下是我正在使用的FodyWeavers.xml。

<?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>

相关内容

最新更新