ReportViewer bug: NullReference exception parsing null date parameters

Andrew Polden 1 Reputation point
2021-03-24T23:17:10.42+00:00

Apologies if this is not the correct place; all obsolete links and roads led me here nonetheless. There appears to be a regression in recent datetime parsing changes to the Windows Forms Report Viewer control in NuGet package Microsoft.ReportingServices.ReportViewerControl.Winforms version 150.1427.0. If I supply a null value for a Date/Time parameter which is set to Allow null value, the report viewer throws a NullReferenceException during load/refresh. The exception is first thrown in the (presumably new) method Microsoft.ReportingServices.Common.DateTimeUtil.ParseDateToAdditionalSettingFormat(String strDateTime, CultureInfo formatProvider). The release notes mention a change concerning datetime parsing. The issue does not occur in the prior version, 150.1404.0.

Repro steps:

  1. Create a new, empty report,
  2. Add one parameter: Date/Time type and allow null values,
  3. Configure the report viewer to load the report, and call LocalReport.SetParameters() with a single ReportParameter object with a null value,
  4. Call RefreshReport(); the exception is thrown.

Trying again, supply a non-null value for the parameter does not cause a problem. Is there a possible work around I might use until this is fixed that I might use, without having revert to the earlier package version?

SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
2,799 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Joyzhao-MSFT 15,566 Reputation points
    2021-03-25T09:08:53.107+00:00

    Hi @Andrew Polden
    There is a similar case before: https://learn.microsoft.com/en-us/answers/questions/265839/systemnullreferenceexception-in-datetimeutilparsed.html
    I found that there is already the latest ReportViewerControl.Winforms version, you could try it and check if the problem is resolved in the latest version.

    If it still doesn’t improve,,I suggest you submit the requirement at https://feedback.azure.com/forums/908035-sql-server.
    If the requirement mentioned by customers for many times, the product team may consider to add this feature in the next SQL Server version. Your feedback is valuable for us to improve our products and increase the level of service provided.
    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.