Page 1 of 1

Multi thread preloading, same report, argument exception

Posted: Wed Nov 14, 2012 2:29 pm
by a.marinelli
I'm trying to load the same report in two different threads (setting different parameters in each thread), but it raises an ArgumentException ("Input string was not in correct format")...

Sample code of what I'm doing:

Code: Select all


static void ThreadPreload1()
{
            String reportToLaunch = @"\\server\path\to\template.mrt";
            StiReport report1 = new StiReport();
            report1.Load(reportToLaunch);
            
            report1.Compile();
            
            string id = @"@pId";

            if (report1.CompiledReport.DataSources["MyData"].Parameters.Contains(id))
                report1.CompiledReport.DataSources["MyData"].Parameters[id].ParameterValue = "20";
            else
                report1.CompiledReport.DataSources["MyData"].Parameters.Add(new Stimulsoft.Report.Dictionary.StiDataParameter(id, "20", 22, 50));
           
            report1.Render(false);
}

static void ThreadPreload2()
{
            String reportToLaunch = @"\\server\path\to\template.mrt";
            StiReport report2 = new StiReport();
            report2.Load(reportToLaunch);
            
            report2.Compile();
            
            string id = @"@pId";

            if (report2.CompiledReport.DataSources["MyData"].Parameters.Contains(id))
                report2.CompiledReport.DataSources["MyData"].Parameters[id].ParameterValue = "25";
            else
                report2.CompiledReport.DataSources["MyData"].Parameters.Add(new Stimulsoft.Report.Dictionary.StiDataParameter(id, "25", 22, 50));
           
            report2.Render(false);
}


private void Preload()
{         
            System.Threading.Thread t = new System.Threading.Thread(ThreadPreload1);
            t.Start();

            System.Threading.Thread t2 = new System.Threading.Thread(ThreadPreload2);
            t2.Start();

}
If I launch only one thread everything is ok; if I launch Thread1 and Thread2 (with Preload() method) I've got the exception.
If I modify ThreadPreload2 to compile a different report it works good with both threads...

What's wrong with my code? I'm missing something about thread safety? :(

thanks in advance

Full error stacktrace:

Code: Select all


System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0

in System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)
   in System.Data.Common.DbConnectionOptions.ParseInternal(Hashtable parsetable, String connectionString, Boolean buildChain, Hashtable synonyms, Boolean firstKey)
   in System.Data.Common.DbConnectionOptions..ctor(String connectionString, Hashtable synonyms, Boolean useOdbcRules)
   in System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   in System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   in System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(String connectionString, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   in System.Data.SqlClient.SqlConnection.ConnectionString_Set(String value)
   in System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
   in System.Data.SqlClient.SqlConnection..ctor(String connectionString)
   in Stimulsoft.Report.Dictionary.StiSqlAdapterService.CreateConnectionInDataStore(StiDictionary dictionary, StiSqlDatabase database)
   in Stimulsoft.Report.Dictionary.StiSqlDatabase.RegData(StiDictionary dictionary, Boolean loadData)
   in Stimulsoft.Report.Dictionary.StiDictionary.CreateDatabases(Boolean loadData)
   in Stimulsoft.Report.Dictionary.StiDictionary.Connect(Boolean loadData)
   in Stimulsoft.Report.Dictionary.StiDictionary.Connect()
   in Stimulsoft.Report.Engine.StiRenderProviderV2.ConnectToData(StiReport report)
   in Stimulsoft.Report.Engine.StiRenderProviderV2.Render(StiReport report, StiRenderState state)
   in Stimulsoft.Report.Engine.StiReportV2Builder.RenderSingleReport(StiReport masterReport, StiRenderState renderState)
   in Stimulsoft.Report.StiReport.RenderReport(StiRenderState renderState)
   in Stimulsoft.Report.StiReport.Render(StiRenderState renderState, StiGuiMode guiMode)
   in Stimulsoft.Report.StiReport.Render(StiRenderState renderState)
   in Stimulsoft.Report.StiReport.Render(Boolean showProgress, Int32 fromPage, Int32 toPage)
   in Stimulsoft.Report.StiReport.Render(Boolean showProgress)
   in BravoClient.Test3.ThreadPreload2() in c:\\Test3.cs:row 260"



Re: Multi thread preloading, same report, argument exception

Posted: Thu Nov 15, 2012 8:57 am
by a.marinelli
I forgot to say that the method that throws the exception is report.Render()...

Re: Multi thread preloading, same report, argument exception

Posted: Thu Nov 15, 2012 1:46 pm
by HighAley
Hello.

As we can see the problem occurs on connection to SQL server.
Please, check if your server let create several connections.
If the problem still exists, please, send us your report template for analysis.

Thank you.