This is a migrated thread and some comments may be shown as answers.

NullReferenceException in WPF ReportViewer

1 Answer 227 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 21 Sep 2012, 12:49 PM
After the recent update to reporting I'm seeing a NullReferenceException when loading a ReportViewer whose ReportSource hasn't been set. My particular use case is that I dynamically create reports based on user input and set the ReportSource through data binding. This means that the report source will be null until the user hits my "generate" button. This is an issue that is a show stopper for a release next week, so any sort of quick help that someone can provide would be greatly appreciated. 

To reproduce you simply need to load any view that has a ReportViewer whose ReportSource hasn't been set.

Here is the stack trace:

   at Telerik.ReportViewer.Wpf.ReportViewerModel.CreateReportSourceSnapshot()
   at Telerik.ReportViewer.Wpf.ReportViewerModel.CreateHistoryRecord(Boolean isTemporary)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.LogHistory(LogHistoryRecord logHistory, Boolean logTemporaryHistoryRecord)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.RefreshReportInternal(Boolean reloadParameters, LogHistoryRecord logHistory, Boolean resetCachedResults)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.RefreshReport()
   at Telerik.ReportViewer.Wpf.ReportViewer.RefreshReport()
   at Telerik.ReportViewer.Wpf.ReportViewer.OnLoaded(Object sender, RoutedEventArgs e)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at MS.Internal.FrameworkObject.OnLoaded(RoutedEventArgs args)
   at System.Windows.BroadcastEventHelper.BroadcastEvent(DependencyObject root, RoutedEvent routedEvent)
   at System.Windows.BroadcastEventHelper.BroadcastLoadedEvent(Object root)
   at System.Windows.Media.MediaContext.FireLoadedPendingCallbacks()
   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()
   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

1 Answer, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 21 Sep 2012, 12:56 PM
Hi Andrew,

We are sorry for hitting this issue. It has already been fixed and the fix will be available in the next internal build or for the official release next month. As a workaround you can simply assign an empty report source (e.g. InstanceReportSource) to the viewer i.e.

reportViewer1.ReportSource = new InstanceReportSource();

All the best,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

Tags
General Discussions
Asked by
Andrew
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or