Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii ,

I am using simple transaction scope in my application , inside which i am inserting employee records into two different database ,

I am using bulk upload to insert the changes , using csv file it retrieves the data and insert the field into the tables .

Now when the data is large i am getting timeout transaction scope problem .

I am using dot net framework 4.0

Please suggest , i tried to give time span into the constructor of transaction scope class .. but still timeout issue ..
Posted
Updated 3-Jul-18 22:16pm

Try this-

In Machine.config

HTML
<configuration> 
  <system.transactions>
    <machinesettings maxtimeout="00:30:00" />
  </system.transactions>
</configuration> 


In App.config
HTML
<system.transactions>
     <defaultsettings timeout="00:30:00" />
</system.transactions>


In case this doesn't work, please let me know.
 
Share this answer
 
Comments
Torakami 30-Oct-14 1:40am    
i tried this solution , only insted of app.config i added those in my web.config file ..but still it is giving me timeout issue when the data is large
Hamza Jawed 2021 31-May-21 8:12am    
Please elaborate where can I find machine.config as I have .net mvc web api project (not core) and I only see web.config and app.config files. Regards!
// This is used for set the transaction timeout to 40 minutes.
Type objSystemType = typeof(global::System.Transactions.TransactionManager);
System.Reflection.FieldInfo oCachedMaxTimeout = objSystemType.GetField("_cachedMaxTimeout", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
System.Reflection.FieldInfo oMaximumTimeout = objSystemType .GetField("_maximumTimeout", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
oCachedMaxTimeout.SetValue(null, true);
oMaximumTimeout.SetValue(null, TimeSpan.FromSeconds(2400));

// For testing to confirm value was changed
// var show=(string.Format("DEBUG SUCCESS!!  Maximum Timeout for transactions is {0}", TransactionManager.MaximumTimeout.ToString()));
 
Share this answer
 
v2
Comments
Richard Deeming 5-Jul-18 11:16am    
Don't resort to private reflection. You can override the setting by changing the configuration file, as shown in solution 1 - four years ago.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900