ReportViewer - 未将对象引用设置为对象的实例

ReportViewer - Object reference not set to an instance of an object

很难让 ReportViewer 控制 运行 个具有可选 (NULL) 参数的报表。

报告在浏览器中直接在 SSRS 上 运行 正常,但是当我尝试在 ASP NET WebForm 应用程序中 运行 它们时,如果可选参数是设置为 null(取消选中 null 复选框)。

我收到这条(误导性的)StackTrace 消息:在 icrosoft.ReportingServices.Common.DateTimeUtil.ParseDateToDefaultFormat => 似乎这是一些日期解析问题,但参数是整数、字符串(不需要日期时间解析)。

我正在使用 Microsoft.ReportViewer.WebForms,版本=15.0.0.0 和 SSRS 2017,示例应用程序是使用此官方文档构建的:https://docs.microsoft.com/en-us/sql/reporting-services/application-integration/integrating-reporting-services-using-reportviewer-controls-get-started?view=sql-server-ver15

升级到 150.1427.0 版本的 nuget 包后,我遇到了同样的问题。当我将 int 或 datetime 值作为参数传递时出现

异常:System.NullReferenceException:对象引用未设置到对象的实例。
在 Microsoft.ReportingServices.Common.DateTimeUtil.ParseDateToDefaultFormat(字符串 strDateTime,CultureInfo formatProvider)
在 Microsoft.Reporting.WebForms.ServerReport.SetParameters(IEnumerable`1 参数)

根据发行说明,他们“修复了影响某些语言环境的日期时间解析问题”。 https://docs.microsoft.com/en-us/sql/reporting-services/application-integration/release-notes-ssrs-application-integration?view=sql-server-ver15

所以我降级到版本 150.1404.0,问题已经解决

如果您升级到版本 150.1449.0(或更高版本),则会解决产生此错误的错误。