Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maxTimeout value from Machine.Config is not picked up by C# winform app

I have been working on a winform app with Oracle 10g database which is using TransactionScope and wanted to modify the maxTimeOut value specified in machine.config file, my machine.config file is in the following location (I am using .net 4 for this app)

C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config 

Originally there was not anything specified for maxTimeOut in it, therefore it defaults to 10 minutes. In order to change it I have added the maxTimeout="00:00:10" value as seen below:

    <sectionGroup name="system.transactions" type="System.Transactions.Configuration.TransactionsSectionGroup, System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null">
        <section name="defaultSettings" type="System.Transactions.Configuration.DefaultSettingsSection, System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null"/>
        <section name="machineSettings" type="System.Transactions.Configuration.MachineSettingsSection, System.Transactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" allowDefinition="MachineOnly" allowExeDefinition="MachineOnly" maxTimeout="00:00:10"/>
    </sectionGroup>

I have restarted the PC and ran a test that lasted longer than this - but the transaction does not appear to abort after 10 seconds, instead the scopeOption.TimeOut value (which is 5 min) specified in TransactionScopeOption parameter is used and the transaction times out after 5 minutes.

Have I included the maxTimeout value into the right place above? Is there anything that needs changing in the file? Why is the value of maxTimeout from machine.config not being used?

Thanks

like image 442
03Usr Avatar asked Nov 28 '22 21:11

03Usr


2 Answers

The reason it was not picked up was because the maxTimeOut value should be placed at the end of the machine.config file just before the closing configuration tag. As soon as I have done it this way it started working.

<configuration>
    <!-- Other configuration sections-->
    <system.transactions>
        <machineSettings maxTimeout="01:00:00" />
    </system.transactions>
</configuration> 
like image 188
03Usr Avatar answered Dec 07 '22 22:12

03Usr


try setting the value in the 32bit machine config

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config 

Could be that the winforms is set for x86 compilation. Also check that there isnt an odac transaction timeout setting and assembly to set as well.

like image 34
nakchak Avatar answered Dec 08 '22 00:12

nakchak