【发布时间】:2019-07-24 20:57:51
【问题描述】:
我有一个使用本地 rdlc 文件生成报告的 Windows 窗体应用程序。这是一个旧应用程序,其中包含多年来使用不同版本的 rdlc 设计器构建的报告(rdlc 文件)。在最后几周,我已经迁移了项目,我决定更新 csproj 文件以使用新的包引用格式。旧项目仍在使用旧版本的报表查看器控件,因此我决定遵循instructions 并安装 Microsoft.ReportingServices.ReportViewerControl.WinForms nuget 包。查看 csproj,我可以看到它正在引用包:
<PackageReference Include="Microsoft.ReportingServices.ReportViewerControl.Winforms">
<Version>150.1358.0</Version>
</PackageReference>
不幸的是,现在我遇到了几个我真的不明白的错误。我收到的第一个错误是报告格式无效。尽管有消息,但问题似乎在于它缺少 Microsoft.ReportViewer.ProcessingObjectModel 程序集。
这是完整的堆栈错误消息:
Microsoft.Reporting.WinForms.LocalProcessingException: An error occurred during local report processing. ---> Microsoft.Reporting.DefinitionInvalidException: The definition of the report '' is invalid. ---> Microsoft.ReportingServices.ReportProcessing.ReportProcessingException: An unexpected error occurred in Report Processing. ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.ReportViewer.ProcessingObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.InternalCompile(AppDomain compilationTempAppDomain, Boolean refusePermissions)
at Microsoft.ReportingServices.RdlExpressions.ExprHostCompiler.<>c__DisplayClass33_0.<Compile>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.RdlExpressions.ExprHostCompiler.Compile(IExpressionHostAssemblyHolder expressionHostAssemblyHolder, AppDomain compilationTempAppDomain, Boolean refusePermissions, PublishingVersioning versioning)
at Microsoft.ReportingServices.ReportPublishing.ReportPublishing.Phase3(ParameterInfoCollection& parameters, Dictionary`2& groupingExprCountAtScope)
at Microsoft.ReportingServices.ReportPublishing.ReportPublishing.InternalCreateIntermediateFormat(Stream definitionStream, String& description, String& language, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CompileOdpReport(PublishingContext reportPublishingContext, PublishingErrorContext errorContext, String& reportDescription, String& reportLanguage, ParameterInfoCollection& parameters, DataSourceInfoCollection& dataSources, DataSetInfoCollection& sharedDataSetReferences, UserLocationFlags& userReferenceLocation, ArrayList& dataSetsName, Boolean& hasExternalImages, Boolean& hasHyperlinks, Byte[]& dataSetsHash)
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CreateIntermediateFormat(PublishingContext reportPublishingContext)
--- End of inner exception stack trace ---
at Microsoft.ReportingServices.ReportProcessing.ReportProcessing.CreateIntermediateFormat(PublishingContext reportPublishingContext)
at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot)
--- End of inner exception stack trace ---
at Microsoft.Reporting.ReportCompiler.CompileReport(ICatalogItemContext context, Byte[] reportDefinition, Boolean generateExpressionHostWithRefusedPermissions, ControlSnapshot& snapshot)
at Microsoft.Reporting.LocalService.GetCompiledReport(PreviewItemContext itemContext, Boolean rebuild, ControlSnapshot& snapshot)
at Microsoft.Reporting.LocalService.CompileReport()
at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
--- End of inner exception stack trace ---
at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession()
at Microsoft.Reporting.WinForms.LocalReport.GetParameters()
at WndAssistencias.Views.frmReportViewer..ctor(RelInfo relInfo) in D:\code\work\tfsonline\AssistenciasHelpdesk\WNDASSISTENCIAS\Views\frmReportViewer.cs:line 32
at WndAssistencias.Presenters.EdicaoPATPresenter.ImprimePatAsync() in D:\code\work\tfsonline\AssistenciasHelpdesk\WNDASSISTENCIAS\Presenters\EdicaoPATPresenter.cs:line 717
好吧,程序集丢失了(我已经确认它不在输出文件夹中)...
如果我没记错的话,当我使用 package.config 引用时,我必须更改程序集引用属性,以便将它们复制到输出中。不幸的是,VS 中的程序集引用列表不再显示报告程序集(它只会显示 nuget 包引用!),所以我不确定如何解决这个问题。
编辑只是补充一点,我已尝试将 processingObjectModel 程序集复制到输出中,但仍然遇到相同的错误。
EDIT2 我已经回到 packages.config 格式并且它正在工作...我有兴趣转到包引用,所以如果有人知道如何解决这个问题(复制辅助程序集到输出文件夹),请告诉我。
有什么线索吗?
谢谢!
【问题讨论】:
标签: c# winforms reportviewer