var printItem = new MenuItem { Header = "Print..." };printItem.Click += (sender, e) => {
var reportSection = new EmbeddedVisualReportSection(this); var report = new Report(); report.Sections.Add(reportSection); report.Export(OutputFormat.XPS, @"c:\test.xps"); // Exports fine the entire grid. report.Print(); //throws CrossThread exception
};gridMenu.Items.Add(printItem);
What could be the reason?
More information:
App is multithreaded.
report.Print(false, false) is printing. But printing without PrintDialog does not make sense for us.
Can you look into this issue please?
This link might help:
http://stackoverflow.com/questions/2972513/printdialog-in-multithreaded-wpf-window-thrown-targetinvocationexception
I would appreciate any feedback on that issue.
Thanks
Thanks.
Hmm .. you 're loosing me here. Could you please point out - may be on the code of my initial post - which lines should be executed in what thread?
Would be great...
The link that you provided accurately explains the problem; there is a bug in the WPF PrintDialog class where it attempts to use the MainWindow which in your case is on another thread. The Report class uses the WPF PrintDialog class when told to show the print dialog so I think the only available workaround until MS fixes the bug in the PrintDialog is to do something like what was marked as an answer in the stackoverflow link you provided. That is, you would show the print dialog using something like the code linked to from that post and then you would set properties on the ReportSettings such as the PrintQueue, PageRange and PageSize.
I see. I'll look deeper into and will get back to you in case.
Somehow my response is not showing in this thread. I am not sure if you received it somehow.
Earlier today I have commented that this issue appeared to me Microsoft related bug with ReportDialog as Andrew pointed out, and our Report class is using WPF ReportDialog.
Sam
Sorry, which "ReportDialog" are you reffering to?
We are bouncing back and forward. I have created different thread for different problem:
http://community.infragistics.com/forums/p/51097/267692.aspx#267692
I should say Microsoft PrintDialog not ReportDialog, in the link you provided.