我创建了一个基本的Azure函数 (.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文件夹中有大量相关的程序集,包括:
这是否与“沙箱”问题有关?如果是,为什么这个错误信息会如此误导?
有没有人在Azure函数中运行微软的本地报告?
发布于 2019-07-25 10:42:54
https://stackoverflow.com/questions/56891704
复制相似问题