Windows Services crashes when calling FastReport

Hey all,

i'm using the FastReport.NET library in a Windows Service. When I start my report generation, the service will crash.

using (Report reportBericht = new Report())
{
	reportBericht.Load(new MemoryStream(Properties.Resources.MyReport));
	reportBericht.SetParameterValue("ConnectionString", ConfigurationManager.ConnectionStrings["DatabaseConnection1"].ConnectionString);                        
	reportBericht.SetParameterValue("id", _pdfReport.Id);
	
	reportBericht.Prepare();
	FastReport.Export.Pdf.PDFExport export = new FastReport.Export.Pdf.PDFExport();
	MemoryStream stream = new MemoryStream();
	reportBericht.Export(export, stream);  
}


I'm using resources for the reports (.frx Files) because I read that there are problems with the root/base directory when using windows services (c:\windows\system32 ...).

I get no usefull error message or stack trace. Only a popup will be displayed and the service will be stopped.

- DatabaseConnection1 is also used for other DB operations in the service, so this should be correct.
- Properties.Resources.MyReport is defined in the "resources" tab of the project - also tried this with a FormApplication project (no service) and it worked - so this should be also okay.

I found some topics in the forum:

https://www.fast-report.com/en/forum/index....showtopic=11596
https://www.fast-report.com/en/forum/index....?showtopic=6332

- Do I have to define the parameter ConnectionString in the report?
- What's the correct usage for the report files (.frx)? Resource? Filesystem?

Thank you guys!

Markus

Comments

  • edited 12:11AM
    The problem I had was a different - but I've found out a way to set the Connection String via C# Service:
    if (reportBericht.Dictionary.Connections.Count > 0)
     {
               DataConnectionBase conn = reportBericht.Dictionary.Connections[0];
               conn.ConnectionString = ConfigurationManager.ConnectionStrings["DatabaseConnection_xxx"].ConnectionString;
     }
    

    DatabaseConnection_xxx has to be set in the app.config
  • edited 12:11AM
    Devart UniDAC and create reports in FastReport I convert pdf windows service with 5 . I've had problems in the beginning but in fastreport1.engineoptions.slientmo = true setting and problem disappeared

Leave a Comment