Page 1 of 1

RTF threading issue with 2021.3

Posted: Thu Jun 10, 2021 8:53 pm
by jcfarsight
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

Re: RTF threading issue with 2021.3

Posted: Tue Jun 15, 2021 8:55 am
by Lech Kulikowski
Hello Justin,

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

Thank you.

Re: RTF threading issue with 2021.3

Posted: Fri Jul 02, 2021 3:18 am
by jcfarsight
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.

Re: RTF threading issue with 2021.3

Posted: Mon Jul 05, 2021 7:53 am
by Lech Kulikowski
Hello,

Thank you for the information.