Wpf Sti functions - thread safety issue
Posted: Tue Sep 09, 2014 4:32 am
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
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