WinForms ReportViewer throws NullReferenceException on displaying report (19.1.25.521)

2 Answers 17 Views
Report Viewer - WinForms
ClausDC
Top achievements
Rank 2
Iron
Iron
ClausDC asked on 18 Jun 2025, 07:11 AM

We just updated Telerik Reporting to 19.1.25.521.

Our application uses WPF but because of historical reasons, we use the WinForms ReportViewer hosted in a WindowsFormsHost control.

Since the latest update (coming from Telerik Reporting Q1 2025), we get a NullReferenceException when the ReportViewer is about to display the report after loading it.

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=Telerik.ReportViewer.WinForms
  StackTrace:
   at Telerik.ReportViewer.WinForms.Licensing.UiLicensePresenter.ShowWatermark(Action showWatermarkCallback)

It seems to have something to do with Licensing? We have manually placed the [assembly: global::Telerik.Licensing.EvidenceAttribute... declarations for Telerik UI for WPF and Telerik Reporting in the project, as it is instructed in your documentation. The regular Telerik WPF controls work fine in our application.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Dimitar
Telerik team
answered on 25 Jun 2025, 02:55 PM

Hello,

We discussed this case in a private ticket with Richard and discovered that there is a bug in the new version related to the licensing watermark applied when a valid license for the product is not found.

A description of the problem can be found in the NullReferenceException thrown by the WinForms Report Viewer when there is no parent form public item.

To avoid this problem, the code must be changed so that the report viewer reference is added to the Controls collection before the RefreshReport() method  is called, for example:

Private Sub ReportViewer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim reportSource1 As UriReportSource = New UriReportSource()
    reportSource1.Uri = "Reports\SampleReport.trdp"
    'reportSource1.Parameters.Add("Parameter1_Name", "Parameter1_Value")
    'reportSource1.Parameters.Add("Parameter2_Name", "Parameter2_Value")

    Dim reportViewer = New Telerik.ReportViewer.WinForms.ReportViewer()
    reportViewer.ReportSource = reportSource1
    reportViewer.Dock = System.Windows.Forms.DockStyle.Fill
    reportViewer.Name = "reportViewer1"
    reportViewer.TabIndex = 1

    Me.Controls.Add(reportViewer)

    reportViewer.RefreshReport()

End Sub

I hope that the provided information will be of help to anyone who encounters this issue until we fix it in a future release.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Ivet
Telerik team
answered on 20 Jun 2025, 02:08 PM

Hello Claus,

Thank you for reaching out.

Based on the stack trace and your description, the NullReferenceException is triggered by the licensing logic in the WinForms ReportViewer, specifically when it tries to display a licensing watermark. This indicates that the WinForms ReportViewer is not detecting a valid Telerik Reporting license file at runtime.

To resolve the issue, you can use the following article - Fixing License Errors in Telerik Reporting Runtime - Telerik Reporting.

Also, could you tell me if you license in the same way as shown in this article - Learn how to set up the Telerik Reporting License Key. - Telerik Reporting?

I hope this helps. Please let me know if you need any further assistance.

      Regards,
      Ivet
      Progress Telerik

      Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

      Richard
      Top achievements
      Rank 1
      Iron
      Iron
      commented on 24 Jun 2025, 09:07 AM | edited

      HI there - I'm having the same issue, but none of the fixes above work. 

      VB.NET / NET8.0 Winforms Project, Embedded report engine NOT report server

      Added Licensing and report viewer NuGet Packages.

        Authenticating with NuGet feed via Windows Auth popup.

      Build states that a "Valid Telerik Reporting license found."

      I've also tried downloading telerik-license.txt and adding that at both a) Solution root and b) project root.

      When I run up the form with the following code;

      Private Sub ReportViewer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
          Dim reportSource1 As UriReportSource = New UriReportSource()
          reportSource1.Uri = "Reports\SampleReport.trdp"
          'reportSource1.Parameters.Add("Parameter1_Name", "Parameter1_Value")
          'reportSource1.Parameters.Add("Parameter2_Name", "Parameter2_Value")

          Dim reportViewer = New Telerik.ReportViewer.WinForms.ReportViewer()
          reportViewer.ReportSource = reportSource1
          reportViewer.Dock = System.Windows.Forms.DockStyle.Fill
          reportViewer.Name = "reportViewer1"
          reportViewer.TabIndex = 1
          reportViewer.RefreshReport()

          Me.Controls.Add(reportViewer)

      End Sub

      The form loads, loads the report viewer with a spinner "Loading report", then crashes out at the following line in UILicenseProvider.cs ( note the .cs - this is a VB.NET project - doubt that's significant however);

      protected override void ShowWatermark(Action showWatermarkCallback)
      {
      if (!base.LicenseInfo.IsValid && CanShowUI())  <========= Null Reference Exception here
      {
      showWatermarkCallback();
      }
      }

      I suspect base.LicenseInfo is null.

      I'm completely blocked by this one - any ideas?

      <EDIT> I've checked and SampleReport.trdp is indeed present in the output directory under Reports/SampleReport.trdp. The report in question was created with the .NET standalone designer, and functions correctly when previewed there </EDIT>

      Tags
      Report Viewer - WinForms
      Asked by
      ClausDC
      Top achievements
      Rank 2
      Iron
      Iron
      Answers by
      Dimitar
      Telerik team
      Ivet
      Telerik team
      Share this question
      or