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

03Usr picture 03Usr · Apr 29, 2013 · Viewed 14.8k times · Source

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

Answer

03Usr picture 03Usr · Apr 30, 2013

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>