Wpf Sti functions - thread safety issue

Stimulsoft Reports.WPF discussion
Post Reply
sandynith
Posts: 64
Joined: Thu Dec 12, 2013 4:03 am

Wpf Sti functions - thread safety issue

Post by sandynith »

Hi,

I am using 2014.1.1900 (WPF) and I have noticed a thread safety issue with the internal Stimulsoft methods.

I have used following set of functions to build, compile and render a stimulsoft report:
report.RegData(table.DataSet);
report.Dictionary.Synchronize();
report.Compile("", StiOutputType.ClassLibrary, false);
report.RenderWithWpf(false);

These works usually fine if only one thread executes them or one report is running. However I have noticed that when above set of functions are called by the multiple threads simultaneously then I get following exceptions:

1.
ReportLauncher.<startReport>b__d Report failed System.ArgumentException: Item has already been added. Key in dictionary: 'System.Data.OleDb.OleDbConnection' Key being added: 'System.Data.OleDb.OleDbConnection'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at Stimulsoft.Base.StiTypeFinder.AddTypeFF(Type exType, Type typeForFinding, Boolean result)
at Stimulsoft.Base.StiTypeFinder.FindInterface(Type exType, Type interfaceForFinding)
at Stimulsoft.Report.Dictionary.StiDataAdapterService.GetDataAdapter(StiData data)
at Stimulsoft.Report.Dictionary.StiDictionary.Synchronize()

2.
ReportLauncher.<startReport>b__d Report failed System.ArgumentException: Item has already been added. Key in dictionary: 'System.Data.SqlClient.SqlConnection' Key being added: 'System.Data.SqlClient.SqlConnection'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at Stimulsoft.Base.StiTypeFinder.AddTypeFF(Type exType, Type typeForFinding, Boolean result)
at Stimulsoft.Base.StiTypeFinder.FindInterface(Type exType, Type interfaceForFinding)
at Stimulsoft.Report.Dictionary.StiDataAdapterService.GetDataAdapter(StiData data)
at Stimulsoft.Report.Dictionary.StiDictionary.Synchronize()

3.
ReportLauncher.<startReport>b__d Report failed System.ArgumentException: Item has already been added. Key in dictionary: 'Stimulsoft.Report.Range' Key being added: 'Stimulsoft.Report.Range'
at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
at System.Collections.Hashtable.Add(Object key, Object value)
at Stimulsoft.Base.StiTypeFinder.AddTypeFF(Type exType, Type typeForFinding, Boolean result)
at Stimulsoft.Base.StiTypeFinder.FindType(Type exType, Type typeForFinding)
at Stimulsoft.Report.CodeDom.StiCodeDomVariables.SerializeVariablesToCode(StiCodeDomSerializator serializator, StiReport report)
at Stimulsoft.Report.CodeDom.StiCodeDomVariables.Serialize(StiCodeDomSerializator serializator, StiReport report)
at Stimulsoft.Report.CodeDom.StiCodeDomSerializator.Serialize(StiReport report, String name, StiLanguage language, Boolean serializeData, Boolean saveForInheritedReports, Object standaloneReportType)
at Stimulsoft.Report.StiReport.ScriptUpdate(Object standaloneReportType, Boolean allowUseResources)
at Stimulsoft.Report.StiReport.Compile(String path, Stream stream, StiOutputType outputType, Boolean autoCreate, Object standaloneReportType)
at Stimulsoft.Report.StiReport.Compile(String path, StiOutputType outputType, Boolean autoCreate)


To avoid this issue I currently put thread synchronization locks around the stimulsoft method calls, however it looks like the Sti functions are NOT thread safe.

Could you please confirm this and possibly advice if I am assuming it wrong.

Thanks,
Sandeep
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Wpf Sti functions - thread safety issue

Post by Alex K. »

Hello,

Can you please send us a sample project which reproduce the issue for analysis.

Thank you.
sandynith
Posts: 64
Joined: Thu Dec 12, 2013 4:03 am

Re: Wpf Sti functions - thread safety issue

Post by sandynith »

Sorry, I am not finding time to build a sample project and its bit hard to reproduce the problem (may be one day). At the moment I am fine by putting locks around stimulsoft library method calls.

Thanks,
Sandeep
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Wpf Sti functions - thread safety issue

Post by Alex K. »

Hello,

Ok.
Let us know if you need any additional help.

Thank you.
Post Reply