2015/04/11

Error message “The definition of the report '' is invalid” when opening a report in Windows Forms ReportViewer.

 

In the brief

I developed a Windows Forms application. There is a ReportViewer control to show some reports. The reports showed up well on my develop machine, but got error message on deployment machine. I finally found that the deployment machine was lack of some assemblies which ReportViewer needs.

Error Message Log

[Error] Message = An error occurred during local report processing. 
   at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession() 
   at Microsoft.Reporting.WinForms.LocalReport.SetParameters(IEnumerable`1 parameters)


[Error] Message = The definition of the report '' is invalid
   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.LocalService.Microsoft.Reporting.ILocalProcessingHost.CompileReport() 
   at Microsoft.Reporting.WinForms.LocalReport.EnsureExecutionSession(), Source = Microsoft.ReportViewer.Common, Method = CompileReport

 

ReporViewer assemblies

In my case, my project is reference Microsoft.ReportViewer.WinForms.dll version 11.0.0.0. All assemblies you need to copy to deployment machine are:

  • Microsoft.ReportViewer.Common.dll
  • Microsoft.ReportViewer.ProcessingObjectModel.dll
  • Microsoft.ReportViewer.WinForms.dll
  • Microsoft.SqlServer.Types.dll

You can find them in c:\windows\assembly\GAC_MSIL\ . Every assembly has its own folder and subfolder of different version.

How I find out the solution

I create an empty report. No parameters, no data source. And open it on deployment machine. Then, I saw the message on ReportViewer as showed below. The message says it needs other assembly to process report.

reportviewer

After I copied Microsoft.SqlServer.Types.dll to my application folder on the deployment machine. It showed next message that it want Microsoft.ReportViewer.ProcessingObjectModel.dll. And then copy it. Finally an empty report showed up. So I change my code to open the normal report which it was be. It works! All reports show up well on deployment machine now.

Final thoughts

Usually I only copy Microsoft.ReportViewer.Common.dll and Microsoft.ReportViewer.WinForms.dll to deployment machine when using ReportViewer version 10. This time I changed my ReportViewer to version 11 and got this error message “The definition of the report '' is invalid”. I googled everywhere but no useful solution for my case. Although someone mentioned it was ReportViewer version issue. But I still don’t know what’s the key point about version issue or what assembly missed in my application. Well, if you has the same problem, report works well on develop machine but not on deployment machine, try this solution.