Error with DataBinding WPF ReportViewer

0 Answers 17 Views
Report Viewer - WPF
almostEric
Top achievements
Rank 1
Iron
Iron
almostEric asked on 03 Jun 2025, 11:10 AM

Hi,

I have a ReportViewer on my XAML page:

<tr:ReportViewer x:Name="LevelAccuracyReportViewer"
                 ReportSource="{Binding LevelAccuracyReportSource}" 
                 Margin="520,360,20,20">
</tr:ReportViewer>

It works ok the first time the page is displayed, but if I update the Source a 2nd time:

LevelAccuracyReportSource = new InstanceReportSource
{
    ReportDocument = levelAccuracyReportDefinition
};

 

I get an "Object Reference not set to instance error", but then it works.
If I update the source again, I get the error message twice, then it works.

Each update causes an additional message to be displayed

I'm using the 2025 Q2 release of Telerik Reporting

Petar
Telerik team
commented on 04 Jun 2025, 08:03 AM

Hello Eric,

The observed behavior looks unusual.

Could you please let me know how exactly you are updating the report source?

Additionally, if you downgrade to the previous 19.0.25.313 version, does the issue still occur?

To further examine the cause of the errors, it would also be very helpful if you could attach a trace listener to the application and provide the generated log file for investigation.

If you are worried about confidentiality, you can open a private support ticket, where we can discuss the issue.

Thank you, and I am looking forward to your reply!

Regards,
Petar
Progress Telerik

almostEric
Top achievements
Rank 1
Iron
Iron
commented on 04 Jun 2025, 12:23 PM

Hi,

I reverted back to the previous version and still got the error.

Here is the complete method that updates the report source (there is an an API call that gets the list of levelAccuracyReport items)

In the applications output, I get the error(s) after the LevelAccuracyReportSource is set but before I see the ProcessReport log start



        private void SetKegLevelAccuracy(IEnumerable<LevelAccuracyReportItem> levelAccuracyReportItems)
        {
            DashboardLevelAccuracyReportDefinition levelAccuracyReportDefinition =
                new DashboardLevelAccuracyReportDefinition
                {
                    objectDataSource = { DataSource = levelAccuracyReportItems },
                };


            LevelAccuracyReportSource = new InstanceReportSource
            {
                ReportDocument = levelAccuracyReportDefinition
            };

        }

 
Petar
Telerik team
commented on 09 Jun 2025, 11:15 AM

Hi Eric,

Thank you for providing the additional details.

The way you are updating the report source looks pretty standard to me.

That said, you mentioned that there is an API call to get the list of the levelAccuracyReportItems. Could you please confirm whether it is not null when you are updating the viewer's report source?

Additionally, the "Object reference not set to an instance" error is too generic to identify the issue's cause right away. May I also see the error's stack trace?

Ideally, the most efficient way for us to offer further assistance would be if you could provide a demo project that reproduces the issue. This would allow us to investigate it locally, identify the cause of the issue, and potentially offer a solution.

Regards,
Petar
Progress Telerik

almostEric
Top achievements
Rank 1
Iron
Iron
commented on 09 Jun 2025, 11:47 AM

Hi,

The data is never null.
Also, I am not generating the Object Reference message - it is being created internally by Telerik, so there is no stack trace (at least none is being generated in my output log)

This is a really large project, not sure how practical it would be to try and create a scaled down demo version

almostEric
Top achievements
Rank 1
Iron
Iron
commented on 09 Jun 2025, 02:15 PM

Not sure if this helps,

If I put a debug break right after the wpf window does its "Initialize components" thing, the first time the window is open, the reportviewer's report source is null (as would be expected) and as mentioned then the source gets set and everything works great.
The next time the window is opened, and the breakpoint is hit, the reportsource is previous binding.
Next, the source gets updated through the data binding updated.
Right after it is changed is when the error is thrown.
At that breakpoint, i tried setting the source back to null, but that actually just made it worse and caused even more object not set errors

Petar
Telerik team
commented on 12 Jun 2025, 10:55 AM

Hello Eric,

Could you please let me know whether your application's target framework is .NET or .NET Framework?

Additionally, would it be possible for me to take a look at the output log? If the error is indeed created internally while processing the report, I would expect it to provide additional details there. For more details on how to attach a trace listener that would generate such a log, please check:

Just make sure you register the trace listener as early as possible at the start of your application to capture all relevant information in the log.

Additionally, I am attaching a sample demo project that targets .NET 8. Could you please let me know if it replicates your scenario or whether there is something I may be missing?

 

almostEric
Top achievements
Rank 1
Iron
Iron
commented on 12 Jun 2025, 01:53 PM

Hi,

Our app targets .net 4.8 (it has been around a while)

Here is the output log.

My notes start with **


**1st Time

BeerDashboard.Operation.exe Information: 0 : Unit.DotsPerInch = 96
BeerDashboard.Operation.exe Information: 0 : Telerik Reporting Assembly Information
BeerDashboard.Operation.exe Information: 0 : ======================================
BeerDashboard.Operation.exe Information: 0 : Name: Telerik.Reporting, Version=19.1.25.521, Culture=neutral, PublicKeyToken=a9d7983dfcc261be; Location: C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Telerik.Reporting\v4.0_19.1.25.521__a9d7983dfcc261be\Telerik.Reporting.dll; TargetFramework: .NETFramework,Version=v4.6.2
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\DigitalPour\Source\BeerDashboard\BeerDashboard.Operation\bin\Debug\QrCodeGenerator.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\netstandard\v4.0_2.0.0.0__cc7b13ffcd2ddd51\netstandard.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
BeerDashboard.Operation.exe Information: 0 : License check for assembly Telerik.Reporting, Version=19.1.25.521, Culture=neutral, PublicKeyToken=a9d7983dfcc261be: True


** ReportSource has now been set

BeerDashboard.Operation.exe Information: 0 : 
BeerDashboard.Operation.exe Information: 0 : *** ReportProcessor.ProcessReport STARTED ***
BeerDashboard.Operation.exe Information: 0 : SQLite x64: v3.33.0
BeerDashboard.Operation.exe Information: 0 : 
BeerDashboard.Operation.exe Information: 0 : *** ProcessReport #0 "Report2" STARTED ***
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Security\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Security.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Net.Http\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Net.Http.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\DigitalPour\Source\BeerDashboard\BeerDashboard.Operation\bin\Debug\System.Memory.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
BeerDashboard.Operation.exe Information: 0 : *** ProcessReport #0 "Report2" DONE in 00:00:00.9644052 ***
BeerDashboard.Operation.exe Information: 0 : 
BeerDashboard.Operation.exe Information: 0 : *** ReportProcessor.ProcessReport DONE in 00:00:01.0081835 ***
BeerDashboard.Operation.exe Information: 0 : 
BeerDashboard.Operation.exe Information: 0 : 
BeerDashboard.Operation.exe Information: 0 : *** Render Report #0 "Report2" STARTED ***
BeerDashboard.Operation.exe Information: 0 : ReportName: Report2; DocumentName: Report2; Extension: WPFXAMLInteractive
BeerDashboard.Operation.exe Information: 0 : DeviceInfo Contents
BeerDashboard.Operation.exe Information: 0 : ===================
BeerDashboard.Operation.exe Information: 0 : BitmapScalingMode: ""
BeerDashboard.Operation.exe Information: 0 : EnableAccessibility: "False"
BeerDashboard.Operation.exe Information: 0 : EnableSearch: "True"
BeerDashboard.Operation.exe Information: 0 : EndPage: "0"
BeerDashboard.Operation.exe Information: 0 : internal_format: "WPFXAMLInteractive"
BeerDashboard.Operation.exe Information: 0 : ProcessItemActions: "True"
BeerDashboard.Operation.exe Information: 0 : ResourceUriTemplate: "{{Binding Path='Images[{0}]'}}"
BeerDashboard.Operation.exe Information: 0 : StartPage: "0"
BeerDashboard.Operation.exe Information: 0 : ValidateXmlCharacters: "True"
BeerDashboard.Operation.exe Information: 0 : WinUIRendering: "False"
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\DigitalPour\Source\BeerDashboard\BeerDashboard.Operation\bin\Debug\MoreLinq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework-SystemXmlLinq\v4.0_4.0.0.0__b77a5c561934e089\PresentationFramework-SystemXmlLinq.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread 67420 has exited with code 0 (0x0).
BeerDashboard.Operation.exe Information: 0 : *** Render Report #0 "Report2" DONE in 00:00:00.5334332 ***
BeerDashboard.Operation.exe Information: 0 : 

** 1st Report Now Displayed


** Now Starting Second Time, the window has loaded, but no databinding has occurred yet

BeerDashboard.Operation.exe Information: 0 : 
BeerDashboard.Operation.exe Information: 0 : *** ReportProcessor.ProcessReport STARTED ***
BeerDashboard.Operation.exe Information: 0 : 
BeerDashboard.Operation.exe Information: 0 : *** ProcessReport #0 "Report2" STARTED ***


** Why is the report starting? I think it is because the Report Source is not null because of the previous time
'BeerDashboard.Operation.exe' (CLR v4.0.30319: BeerDashboard.Operation.exe): Loaded 'C:\DigitalPour\Source\BeerDashboard\BeerDashboard.Operation\bin\Debug\System.ValueTuple.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. BeerDashboard.Operation.exe Information: 0 : *** ProcessReport #0 "Report2" DONE in 00:01:37.6463930 *** BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : *** ReportProcessor.ProcessReport DONE in 00:01:37.6561720 *** BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : *** Render Report #0 "Report2" STARTED *** BeerDashboard.Operation.exe Information: 0 : ReportName: Report2; DocumentName: Report2; Extension: WPFXAMLInteractive BeerDashboard.Operation.exe Information: 0 : DeviceInfo Contents BeerDashboard.Operation.exe Information: 0 : =================== BeerDashboard.Operation.exe Information: 0 : BitmapScalingMode: "" BeerDashboard.Operation.exe Information: 0 : EnableAccessibility: "False" BeerDashboard.Operation.exe Information: 0 : EnableSearch: "True" BeerDashboard.Operation.exe Information: 0 : EndPage: "0" BeerDashboard.Operation.exe Information: 0 : internal_format: "WPFXAMLInteractive" BeerDashboard.Operation.exe Information: 0 : ProcessItemActions: "True" BeerDashboard.Operation.exe Information: 0 : ResourceUriTemplate: "{{Binding Path='Images[{0}]'}}" BeerDashboard.Operation.exe Information: 0 : StartPage: "0" BeerDashboard.Operation.exe Information: 0 : ValidateXmlCharacters: "True" BeerDashboard.Operation.exe Information: 0 : WinUIRendering: "False" BeerDashboard.Operation.exe Information: 0 : *** Render Report #0 "Report2" DONE in 00:00:00.0819050 *** BeerDashboard.Operation.exe Information: 0 : ** The databinding has now been set, and the "Object Reference" message is now displaying ** This is the actual 2nd report which works: BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : *** ReportProcessor.ProcessReport STARTED *** BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : *** ProcessReport #0 "Report2" STARTED *** BeerDashboard.Operation.exe Information: 0 : *** ProcessReport #0 "Report2" DONE in 00:00:05.9367594 *** BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : *** ReportProcessor.ProcessReport DONE in 00:00:05.9434326 *** BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : BeerDashboard.Operation.exe Information: 0 : *** Render Report #0 "Report2" STARTED *** BeerDashboard.Operation.exe Information: 0 : ReportName: Report2; DocumentName: Report2; Extension: WPFXAMLInteractive BeerDashboard.Operation.exe Information: 0 : DeviceInfo Contents BeerDashboard.Operation.exe Information: 0 : =================== BeerDashboard.Operation.exe Information: 0 : BitmapScalingMode: "" BeerDashboard.Operation.exe Information: 0 : EnableAccessibility: "False" BeerDashboard.Operation.exe Information: 0 : EnableSearch: "True" BeerDashboard.Operation.exe Information: 0 : EndPage: "0" BeerDashboard.Operation.exe Information: 0 : internal_format: "WPFXAMLInteractive" BeerDashboard.Operation.exe Information: 0 : ProcessItemActions: "True" BeerDashboard.Operation.exe Information: 0 : ResourceUriTemplate: "{{Binding Path='Images[{0}]'}}" BeerDashboard.Operation.exe Information: 0 : StartPage: "0" BeerDashboard.Operation.exe Information: 0 : ValidateXmlCharacters: "True" BeerDashboard.Operation.exe Information: 0 : WinUIRendering: "False" The thread 41856 has exited with code 0 (0x0). BeerDashboard.Operation.exe Information: 0 : *** Render Report #0 "Report2" DONE in 00:00:00.1010667 *** BeerDashboard.Operation.exe Information: 0 :


Petar
Telerik team
commented on 17 Jun 2025, 03:50 PM

Hi Eric,

Thank you for providing the log.

I was hoping for the error to be somehow mentioned there (which would be the case if it occurred while processing the report), but your insights still helped gain a better understanding of the issue.

Have you tried rendering a different report file (for example, a simple one with a single textbox)? Does the issue occur there?

I am attaching a sample WPF .NET Framework application that dynamically updates the report source. Please take a look at it and let me know if there is anything related missing from your configuration. You can also try rendering your own report instead. If you are able to reproduce the issue, I would appreciate it if you could send a copy of the application so we can investigate it further.

Thank you!

No answers yet. Maybe you can help?

Tags
Report Viewer - WPF
Asked by
almostEric
Top achievements
Rank 1
Iron
Iron
Share this question
or