RTF threading issue with 2021.3

Stimulsoft Reports.Wpf discussion
Post Reply
jcfarsight
Posts: 9
Joined: Tue Jul 24, 2018 3:18 am

RTF threading issue with 2021.3

Post by jcfarsight » Thu Jun 10, 2021 8:53 pm

Greetings,
We've just upgraded our Stimulsoft WPF library from 2020.5.2 to 2021.3.2 and it has started causing a problem when we upload an RTF disclaimer file.

Because we need to set the CanShrink/CanGrow properties to true, StiRichText requires the rendering to be done on an STA thread. This used to work in the old version but we are now encountering this exception:

StiUtil.<InternalRenderReport>b__0 The calling thread cannot access this object because a different thread owns it.
StiUtil.<InternalRenderReport>b__0 at System.Windows.Threading.Dispatcher.VerifyAccess()
at System.Windows.DependencyObject.GetValue(DependencyProperty dp)
at System.Windows.Media.SolidColorBrush.get_Color()
at Stimulsoft.Report.Wpf.ControlsV2.StiWpfV2ThemeHelper.InitResourcesForOffice2013Theme(ResourceDictionary dict1)
at Stimulsoft.Report.Wpf.ControlsV2.StiWpfV2ThemeHelper.LoadControlTheme(IStiWpfV2Control control)
at Stimulsoft.Report.Painters.StiRichTextWpfPainter.Measure(Double width, StiComponent comp)
at Stimulsoft.Report.Components.StiRichText.GetActualSize()
at Stimulsoft.Report.Components.StiContainerHelper.CheckSize(StiComponent component)
at Stimulsoft.Report.Engine.StiContainerV2Builder.InternalRender(StiComponent masterComp)
at Stimulsoft.Report.Engine.StiEngine.InternalRenderBand(StiBand band, Boolean ignorePageBreaks, Boolean allowRenderingEvents, Boolean& isChildsEnabled)
at Stimulsoft.Report.Engine.StiEngine.RenderBand(StiBand band, Boolean ignorePageBreaks, Boolean allowRenderingEvents)
at Stimulsoft.Report.Engine.StiPageHelper.RenderPage(StiPage page)
at Stimulsoft.Report.Engine.StiRenderProviderV2.RenderReport(StiReport report, StiReport masterReport, StiRenderState state)
at Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
at Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
at Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
at Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
at Stimulsoft.Report.StiReport.RenderWithWpf(Boolean showProgress)

Could you please advise whether there is a solution we can implement?

Regards,
Justin
Lech Kulikowski
Posts: 3815
Joined: Tue Mar 20, 2018 5:34 am

Re: RTF threading issue with 2021.3

Post by Lech Kulikowski » Tue Jun 15, 2021 8:55 am

Hello Justin,

Please send us a sample project that reproduces the issue for analysis.

Thank you.
jcfarsight
Posts: 9
Joined: Tue Jul 24, 2018 3:18 am

Re: RTF threading issue with 2021.3

Post by jcfarsight » Fri Jul 02, 2021 3:18 am

I had a go at producing a sample application but due to the issue being thread/dispatcher related (plus observables in the mix) I found it easier to just solve the problem on our end.

We were previously generating reports from an MTA WPF dispatcher thread and then creating a new STA thread to render the report (as Rich Text controls seem to require it).
I've now shunted the whole pipeline onto an STA thread to get around this problem.
Lech Kulikowski
Posts: 3815
Joined: Tue Mar 20, 2018 5:34 am

Re: RTF threading issue with 2021.3

Post by Lech Kulikowski » Mon Jul 05, 2021 7:53 am

Hello,

Thank you for the information.
Post Reply