I used Microsoft ReportViewer in remote mode to view reports which are stored locally. The code seems to be unable to upload reports to SQL 2016 (While working well with SQL 2014) with NullReferenceException
on command ServerReport.LoadReportDefinition(...)
.
Is there an error in my code or is it a ReportViewer
bug? Is there any setting omitted?
I know about What is a NullReferenceException, and how do I fix it?, but I am getting the exception from depth of Microsoft code and none of the objects I can access is null.
Steps to reproduce
- Create a new winforms project
- To the Form1 add Reporting/ReportViever from the Toolbox (
reportViewer1
) Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms
(the version 140.1000.523 october 2017 is installed)- Paste (with a modification of the report path and server name) the following code to the Form1:
private void Form1_Load(object sender, EventArgs e)
{
reportViewer1.ProcessingMode = ProcessingMode.Remote;
reportViewer1.ShowCredentialPrompts = true;
reportViewer1.ServerReport.ReportServerUrl =new Uri("http://MyServer/ReportServer");
using (var tr = System.IO.File.OpenText(@"c:\ ... \MyReport.rdl"))
{
reportViewer1.ServerReport.LoadReportDefinition(tr);
}
this.reportViewer1.RefreshReport();
}
When MyServer
is SQL Server 2014 the report is rendered in the viewer as expected. When the server is SQL Server 2016 (or even 2017) I am getting NullReferenceException
and ReportServerException
(one after the other after F5) on the line reportViewer1.ServerReport.LoadReportDefinition
. I believe that the second exception is the consequence of the first one.
Full exception:
First:
System.NullReferenceException was unhandled
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Microsoft.ReportViewer.WinForms
StackTrace:
at Microsoft.Reporting.WinForms.SoapReportExecutionService.SoapExecutionInfoToParametersLayout(ParametersPaneLayout paramPaneLayout, ExecutionInfo3 soapExecInfo3, ReportParameterInfoCollection paramInfoCollection)
at Microsoft.Reporting.WinForms.SoapReportExecutionService.FromSoapExecutionInfo(ExecutionInfo soapExecutionInfo)
at Microsoft.Reporting.WinForms.SoapReportExecutionService.LoadReportDefinition(Byte[] definition)
at Microsoft.Reporting.WinForms.ServerReport.LoadReportDefinition(TextReader report)
at SSRSTestC.Form1.Form1_Load(Object sender, EventArgs e) in C:\MyDiskArea\LiveProgProjects\SSRSTestC\SSRSTestC\Form1.cs:line 24
...
InnerException:
null
Second
Microsoft.Reporting.WinForms.ReportServerException was unhandled
ErrorCode=rsInvalidReportDefinition
HResult=-2146233088
Message=The definition of this report is not valid or supported by this version of Reporting Services. The report definition may have been created with a later version of Reporting Services, or contain content that is not well-formed or not valid based on Reporting Services schemas. Details: Root element is missing. (rsInvalidReportDefinition)
Source=Microsoft.ReportViewer.WinForms
StackTrace:
at Microsoft.Reporting.WinForms.SoapReportExecutionService.ServerReportSoapProxy.OnSoapException(SoapException e)
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.ProxyMethodInvocation.Execute[TReturn](RSExecutionConnection connection, ProxyMethod`1 sql16Method, ProxyMethod`1 katmaiMethod, ProxyMethod`1 yukonMethod)
at Microsoft.Reporting.WinForms.Internal.Soap.ReportingServices2005.Execution.RSExecutionConnection.LoadReportDefinition(Byte[] Definition, Warning[]& warnings)
at Microsoft.Reporting.WinForms.SoapReportExecutionService.LoadReportDefinition(Byte[] definition)
at Microsoft.Reporting.WinForms.ServerReport.LoadReportDefinition(TextReader report)
at SSRSTestC.Form1.Form1_Load(Object sender, EventArgs e) in C:\MyDiskArea\LiveProgProjects\SSRSTestC\SSRSTestC\Form1.cs:line 24
...
InnerException:
null
The report, when opened in the Report Builder 2014, can be rendered on both servers without any problem. When the report is already uploaded on a server (.ReportPath =
replaces .LoadReportDefinition(
) the Report Viewer control can render it.
Edit
The problem is now reported to Microsoft SSRS report viewer crashes when uploading a report to Report Sever 2016