FR hangs while trying to export
Hi, I use the newest fastreport.mono with Windows.
I have a really simple example with just a footer in it and i Register no data f??r the Export.
My issue is, that fastreport is not responding and won't show the SaveFile-dialog after choosing an Export to file type.
With Fastreport.net it works perfectly fine, with mono not. It does not matter which Export type I choose.
What could be the reason for not showing the SaveFile Dialog?
regards
I have a really simple example with just a footer in it and i Register no data f??r the Export.
My issue is, that fastreport is not responding and won't show the SaveFile-dialog after choosing an Export to file type.
With Fastreport.net it works perfectly fine, with mono not. It does not matter which Export type I choose.
What could be the reason for not showing the SaveFile Dialog?
regards
This discussion has been closed.
Comments
I tried it out in a simple console application. it Showed me in VisualStudio an exception that the main procedure must be marked as STAThread. Compiled -> it hangs as described.
Ok but i cannot Change my application to be STAThreaded. what Solutions exist? (I really dont want to start a new STA Threaded exe to avoid this)
It Runs.
Hello!
Pass the path to the output file as the second argument to the Export() method. In this case, FastReport does not display the SaveFileDialog:
using (var report = new Report()) { report.Load(‘report.frx’); report.Prepare(); using (var pdf = new FastReport.Export.Pdf.PDFExport()) { pdf.ShowProgress = false; // Suppress the progress bar report.Export(pdf, ‘result.pdf’); } }Export directly to a stream (Stream):
using (var fs = new FileStream(‘result.pdf’, FileMode.Create, FileAccess.Write)) using (var pdf = new FastReport.Export.Pdf.PDFExport { ShowProgress = false }) { report.Export(pdf, fs); }You can also globally suppress any attempts to display UI dialogues by setting the property Config.WebMode = true;
You have also correctly identified the root cause: the standard file-save dialogue (SaveFileDialog) in WinForms/COM requires ApartmentState.STA, and calling it from an MTA thread causes the programme to freeze.