Reports and Threads

jeromejerome France
edited 5:59AM in FastReport .NET
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.

Comments

  • edited 5:59AM
    Hello,

    Do you use RichObject object inside of your reports?
  • jeromejerome France
    edited 5:59AM
    AlexTZ wrote: »
    Hello,

    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.
  • edited 5:59AM
    RichObject incapsulates the Windows RichTextBox and has many limitations. One of them is that you should dispose the report when you no longer need 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.
  • jeromejerome France
    edited 5:59AM
    AlexTZ wrote: »
    RichObject incapsulates the Windows RichTextBox and has many limitations. One of them is that you should dispose the report when you no longer need 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 >

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.