FR hangs while trying to export

edited August 2014 in FastReport.Mono
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

Comments

  • edited 6:46PM
    i know why it hangs.

    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)
  • edited 6:46PM
    I created a new Thread and Set apartmenttype to STA.
    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.

This discussion has been closed.