SSRS 2016:将报表加载到服务器时出现 NullReferenceException 和 ReportServerException
SSRS 2016: NullReferenceException and ReportServerException when loading a report to the server
我在 远程 模式下使用 Microsoft ReportViewer 查看存储在本地的报告。该代码似乎无法 将报告 上传到 SQL 2016(虽然与 SQL 2014 一起工作良好)命令 NullReferenceException
ServerReport.LoadReportDefinition(...)
.
我的代码有错误还是 ReportViewer
错误?是不是省略了什么设置?
我知道 What is a NullReferenceException, and how do I fix it?,但我从 Microsoft 代码的深度得到了异常,我可以访问的对象中有 none 是 null。
重现步骤
- 创建一个新的 winforms 项目
- 向 Form1 添加工具箱中的 Reporting/ReportViever (
reportViewer1
)
Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms
(安装版本140.1000.523 october 2017)
- 将以下代码粘贴(修改报表路径和服务器名称)到 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
行。我相信第二个例外是第一个例外的结果。
完全异常:
第一个:
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
第二个
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
报表在 Report Builder 2014 中打开时,可以毫无问题地在两台服务器上呈现。当报表已上传到服务器时(.ReportPath =
替换 .LoadReportDefinition(
),Report Viewer 控件可以呈现它。
编辑
问题已报告给Microsoft SSRS report viewer crashes when uploading a report to Report Sever 2016
我不熟悉 LoadReportDefintion API,但是从调用堆栈来看,LoadReportDefinition API 调用没有通过 Publish RDL 路径中的 upgrade\downgrade 代码路径.
请将您的报告升级到 2016 架构、最新的 Report Builder 或 SSDT,然后重试。
问题现已在 Microsoft.ReportingServices.ReportViewerControl.Winforms 150.900.148 中得到纠正。
在向开发团队报告问题后,我被要求提供更详细的信息,问题得到确认和更正。 (感谢 Brad Syputa - Microsoft)。
我在 远程 模式下使用 Microsoft ReportViewer 查看存储在本地的报告。该代码似乎无法 将报告 上传到 SQL 2016(虽然与 SQL 2014 一起工作良好)命令 NullReferenceException
ServerReport.LoadReportDefinition(...)
.
我的代码有错误还是 ReportViewer
错误?是不是省略了什么设置?
我知道 What is a NullReferenceException, and how do I fix it?,但我从 Microsoft 代码的深度得到了异常,我可以访问的对象中有 none 是 null。
重现步骤
- 创建一个新的 winforms 项目
- 向 Form1 添加工具箱中的 Reporting/ReportViever (
reportViewer1
) Install-Package Microsoft.ReportingServices.ReportViewerControl.Winforms
(安装版本140.1000.523 october 2017)- 将以下代码粘贴(修改报表路径和服务器名称)到 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
行。我相信第二个例外是第一个例外的结果。
完全异常:
第一个:
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
第二个
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
报表在 Report Builder 2014 中打开时,可以毫无问题地在两台服务器上呈现。当报表已上传到服务器时(.ReportPath =
替换 .LoadReportDefinition(
),Report Viewer 控件可以呈现它。
编辑
问题已报告给Microsoft SSRS report viewer crashes when uploading a report to Report Sever 2016
我不熟悉 LoadReportDefintion API,但是从调用堆栈来看,LoadReportDefinition API 调用没有通过 Publish RDL 路径中的 upgrade\downgrade 代码路径.
请将您的报告升级到 2016 架构、最新的 Report Builder 或 SSDT,然后重试。
问题现已在 Microsoft.ReportingServices.ReportViewerControl.Winforms 150.900.148 中得到纠正。
在向开发团队报告问题后,我被要求提供更详细的信息,问题得到确认和更正。 (感谢 Brad Syputa - Microsoft)。