1

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

  1. Create a new winforms project
  2. To the Form1 add Reporting/ReportViever from the Toolbox (reportViewer1)
  3. Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms (the version 140.1000.523 october 2017 is installed)
  4. 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

IvanH
  • 4,686
  • 13
  • 55
  • 71
  • 1
    I agree that here the nullreferenceexception is a symptom and not the cause. We should focus on "Root element is missing. (rsInvalidReportDefinition)" but I am afraid this too is just a symptom of failed SOAP service communication: [poor google harvest](https://social.msdn.microsoft.com/Forums/aspnet/en-US/b7537f82-7aaa-45e1-9a74-de860f5291b2/loadreportdefinitiongterror-quotroot-element-is-missingquot?forum=vsreportcontrols) – Cee McSharpface Sep 04 '18 at 08:03

2 Answers2

0

The problem is now corrected in Microsoft.ReportingServices.ReportViewerControl.Winforms 150.900.148.

After reporting the problem to the development team I was asked to provide more detailed information and the problem was confirmed and corrected. (Thanks to Brad Syputa - Microsoft).

IvanH
  • 4,686
  • 13
  • 55
  • 71
-1

I am not familiar with the LoadReportDefintion API, but from seeing the callstack, the LoadReportDefinition API call does not go through upgrade\downgrade code path that is in the Publish RDL path.

Please upgrade your report to the 2016 schema, the latest Report Builder or SSDT and try again.

  • I have started my experiments with a report created with latest version of Report builder and latest version of the viever and it failed. The process presented in the question is minimal exammple (using older report usable on both servers). – IvanH Sep 06 '18 at 18:03