azure-functions - Azure 函数中的 Microsoft 报告 LocalReport:ReportProcessingException
问题描述
我创建了一个基本的Azure Function (.NET),我有一个生成LocalReport(基于 WinForms)的基本项目。这适用于 ASP.NET MVC 应用程序和单元测试,但不适用于 Azure 函数。
不完全是这样,但你得到了这个想法:
[FunctionName("Report")]
public static async Task<HttpResponseMessage> Report([HttpTrigger(AuthorizationLevel.Function, "POST", Route = "Report")]HttpRequestMessage req, ILogger log)
{
Microsoft.Reporting.WinForms.LocalReport lr = new Microsoft.Reporting.WinForms.LocalReport();
lr.ReportPath = "Sales.rdlc";
lr.DataSources.Add(new ReportDataSource("Sales", GetSalesData()));
// this line fails:
var bytes = lr.Render("PDF", null, out mimeType, out encoding, out streamids, out warnings);
response.Content = new ByteArrayContent(bytes);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");
return await Task.FromResult(response);
}
执行时lr.Render("PDF", ...)
,会出现以下错误:
Microsoft.Reporting.WinForms.LocalProcessingException
HResult=0x80131500
Message=An error occurred during local report processing.
Source=Microsoft.ReportViewer.WinForms
StackTrace:
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, CreateAndRegisterStream createStreamCallback, Warning[]& warnings)
at Microsoft.Reporting.WinForms.LocalReport.InternalRender(String format, Boolean allowInternalRenderers, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
at Microsoft.Reporting.WinForms.LocalReport.Render(String format, String deviceInfo, PageCountMode pageCountMode, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
at Microsoft.Reporting.WinForms.Report.Render(String format, String deviceInfo, String& mimeType, String& encoding, String& fileNameExtension, String[]& streams, Warning[]& warnings)
Inner Exception 1:
ReportProcessingException: Failed to load expression host assembly. Details: Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=15.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies.
我真的看不出丢失的程序集是什么,但我的bin
文件夹中有很多相关的程序集,包括:
- Microsoft.ReportViewer.Common.dll
- Microsoft.ReportViewer.Common.resources.dll
- Microsoft.ReportViewer.DataVisualization.dll
- Microsoft.ReportViewer.DataVisualization.resources.dll
- Microsoft.ReportViewer.Design.dll
- Microsoft.ReportViewer.Design.resources.dll
- Microsoft.ReportViewer.ProcessingObjectModel.dll
- Microsoft.ReportViewer.WinForms.dll
- Microsoft.ReportViewer.WinForms.resources.dll
- Microsoft.SqlServer.Types.dll
- 还有很多...
这可能与“沙盒”问题有关吗?如果是,为什么此错误消息如此具有误导性?
有人在 Azure Functions 中运行 Microsoft 本地报告吗?
解决方案
推荐阅读
- java - 当有多个注入组件候选注入时,spring如何进行依赖注入
- azure-machine-learning-studio - 使用 Azure 机器学习设计器从 DataStore 创建 DataSet 时登录失败
- javascript - 在从服务器获取的选择(选项)中追加数据
- flutter - 颤振哨兵未定义功能'runZonedGuarded'
- angular - 打字稿:参数类型字符串 [] 不能分配给参数类型任何
- io - 操作系统如何处理输入操作?
- c# - 根据复选框状态添加/删除用户控件。如果已检查用户控件添加正确但无法删除
- google-bigquery - 关于引用列位置和列数的 CSV 表的错误
- php - 显示来自存储路径 laravel 的文件
- python - “AttributeError:‘模块’对象没有属性‘CUIAutomation’”