SSRS 2016:将报表加载到服务器时的 NullReferenceException 和 ReportServerE



我在远程模式下使用Microsoft ReportViewer来查看存储在本地的报告。该代码似乎无法将报告上传到SQL 2016(同时与SQL 2014配合良好(,NullReferenceException命令ServerReport.LoadReportDefinition(...)

我的代码中是否存在错误或ReportViewer错误?是否省略了任何设置?

我知道什么是 NullReferenceException,以及如何修复它?,但我从Microsoft代码深度得到异常,我可以访问的对象都不是空的。

重现步骤

  1. 创建新的 winforms 项目
  2. 在 Form1 中添加 报告/报告从工具箱 (reportViewer1(
  3. Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms(已安装版本 140.1000.523 2017 年 10 月(
  4. 将以下代码粘贴(修改报表路径和服务器名称(到 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();
}

MyServer是 SQL Server 2014 时,报表将按预期在查看器中呈现。当服务器是SQL Server 2016(甚至2017(时,我在行reportViewer1.ServerReport.LoadReportDefinition上得到NullReferenceExceptionReportServerException(F5之后一个接一个(。我认为,第二个例外是第一个例外的结果。

完全例外:

第一:

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:MyDiskAreaLiveProgProjectsSSRSTestCSSRSTestCForm1.cs:line 24
...
InnerException: 
null     

第二

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:MyDiskAreaLiveProgProjectsSSRSTestCSSRSTestCForm1.cs:line 24
...    
InnerException: 
null

在报表生成器 2014中打开报表时,可以在两台服务器上呈现,没有任何问题。当报表已上载到服务器上(.ReportPath =替换.LoadReportDefinition((时,报表查看器控件可以呈现它。
编辑

现在报告此问题Microsoft SSRS 报表查看器在将报表上载到报表服务器 2016 时崩溃

此问题现已在 Microsoft.ReportingServices.ReportViewerControl.Winforms 150.900.148 中得到纠正。

在向开发团队报告问题后,我被要求提供更详细的信息,问题得到了确认和纠正。(感谢布拉德·西普塔 - Microsoft(。

我不熟悉 LoadReportDefintion API,但从调用堆栈来看,LoadReportDefinition API 调用不会经过发布 RDL 路径中的升级\降级代码路径。

请将报表升级到 2016 架构、最新的报表生成器或 SSDT,然后重试。

最新更新