Skip to Content
0
Former Member
Jan 08, 2014 at 04:13 PM

How to render report asynchronous with WPF?

172 Views

Hi

We use CR13 in a project. This is a WPF solution. How i can render the report asynchronous with the CrystalReportsViewer control?

When I start the form in a new thread, not the main UI thread, then crashed the CrystalReportsViewer control.

System.NullReferenceException was unhandled

Message: An unhandled exception of type 'System.NullReferenceException' occurred in SAPBusinessObjects.WPF.Viewer.dll

Additional information: Object reference not set to an instance of an object.

With this code work the CrystalReportsViewer, but the main UI is blocked.

public void OpenCrystalReport(ReportGeneratorModel model)

{

if (Thread.CurrentThread == this.Dispatcher.Thread)

{

//show report in crystalreportviewer

CristalReportForm frm = new CristalReportForm(model);

if (model.ShowOnScreen)

{

frm.Show();

}

}

else

{

Action<ReportGeneratorModel> delaget = this.OpenCrystalReport;

this.Dispatcher.Invoke(delaget, new object[] { model });

}

}

With this code we have a NullReferenceException.

public void OpenCrystalReport(ReportGeneratorModel model)

{

//show report in crystalreportviewer

CristalReportForm frm = new CristalReportForm(model);

if (model.ShowOnScreen)

{

frm.Show();

}

}

How to start the rendering nonblocking?