Microsoft Reports LocalReport in Azure Function: ReportProcessingException

1

I created a basic Azure Function (.NET), I have a basic Project which generates a LocalReport (WinForms based). This works within a ASP.NET MVC Application and within Unit Tests, but not in Azure Function.

Not quite exactly as this, but you get the Idea:

[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);
}

When lr.Render("PDF", ...) is executed, the following error is raised:

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.

I don't really see what the missing assembly could be, but I have loads of related assemblies right in my bin folder, including:

  • 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
  • Any many more...

Could this be related to the "sandbox" issue? If yes, why is this error message so misleading?

Has anybody got Microsoft local reports running inside Azure Functions?

azure-functions
ms-reports
asked on Stack Overflow Jul 4, 2019 by thmshd

1 Answer

0

User contributions licensed under CC BY-SA 3.0