Reports and Threads
jerome
France
Hi!
I'm using FastReport mostly in the C# code for some apps.
This time, I had to make one or several reports depending on some graphical elements in my app.
I create nearly every field of my report in the code, and I fill those fields thanks to the elements in my app
( e.g : MyTextObject.Text = myLabel.Content.ToString(); )
Usually it works fine, I've been using it for several months but now I have a strange error and the reports are concerned obviously (the error only appears when I enable reports).
The error message (translated to English) is the following : "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."
I guess it comes from the method PrepareReport() but I'm not sure.
Is there any known problem about that? Is there any solution? Am I correct to use the visual controls directly to fill the report like the exemple above?
Thanks for your help.
I'm using FastReport mostly in the C# code for some apps.
This time, I had to make one or several reports depending on some graphical elements in my app.
I create nearly every field of my report in the code, and I fill those fields thanks to the elements in my app
( e.g : MyTextObject.Text = myLabel.Content.ToString(); )
Usually it works fine, I've been using it for several months but now I have a strange error and the reports are concerned obviously (the error only appears when I enable reports).
The error message (translated to English) is the following : "Cross-thread operation not valid: Control '' accessed from a thread other than the thread it was created on."
I guess it comes from the method PrepareReport() but I'm not sure.
Is there any known problem about that? Is there any solution? Am I correct to use the visual controls directly to fill the report like the exemple above?
Thanks for your help.
Comments
Do you use RichObject object inside of your reports?
Yes I do use RichObject inside this report.
Do you think it comes from that control? Indeed, it's the first time I use it.
report.Dispose();
Do not rely on the Garbage Collector - it disposes the report in its own thread that is different from your main application thread. This may cause the problem with RichObject.
Thanks a lot, I'll try this