Mark Whiting
Mark Whiting

Reputation: 11

ReportViewerCore.NETCore running rdlc report generates error

I am trying to generate a Microsoft.Reporting.WinForms.LocalReport (rdlc file as embedded resource in my class library project) in NET 6.0 VS 2022 (v17.2.4).

Running on my local development machine it works fine, but when I copy my debug folder to the test machine, when it calls the line...

byte[] bytes = Report.Render("PDF");

...I get the following error...

22/06/2022 10:42:10 - Error saving report JobInfo: 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.InvalidOperationException: (20) : error BC30002: Type 'System.Reflection.AssemblyVersion' is not defined. --- End of inner exception stack trace --- at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession() 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) at Microsoft.Reporting.WinForms.Report.Render(String format, String deviceInfo) at Microsoft.Reporting.WinForms.Report.Render(String format) at Sales.Demo.ManageReport.SaveReport(DataTable ReportData, String reportName, String reportResourceFilePath, String reportFilePath)

I am sure that the report name is populated and correct.

I saw a post saying that the rdlc file format could be incorrect, but then it wouldn't work on my local machine.

I tried using Microsoft.Reporting.NETCore.LocalReport instead of the WinForms but same result.

I have also tried installing all dependency packages in case this was the issue.

What am I doing wrong?! Many thanks in advance for any help you can give me.

UPDATE: The report only works if I run the program in debug in VS on my local machine. Running the program directly from its exe gives me this error also. The report file is not in the executable directory. My project is a 'plug-in' to the executing program in a sub-directory.

Upvotes: 0

Views: 1065

Answers (1)

Nick Pitman
Nick Pitman

Reputation: 11

I had a similar issue which I managed to resolve. In my case, I was programming a console app in vs2022 net6.0 which generated a report rendered into Byte[]. But I was using ReportViewerCore.NETCore nuget.

Worked fine on the development PC but after publishing it and running on a server as a service I had the dreaded The definition of the report '' is invalid.

I added all the dependencies as described listed in the nuget - still no joy. Then I noticed that running the exe file on the publish folder on the development PC had the same error which seemed strange as that PC had all the DLLs required. After lots of experimenting, I found that unticking the 'Produce single file' under the Publish option in VS2022 resolved the issue

enter image description here

I realize that there are many other reasons for this error and you are using Microsoft.Reporting.WinForms and not ReportViewerCore.NETCore but the issue did seem very similar.

Upvotes: 0

Related Questions