[Machine.Config中的maxTimeout值未被C#winform应用程序拾取

问题描述 投票:4回答:2

我一直在使用带有TransactionScope的Oracle 10g数据库来开发Winform应用程序,并且想要修改machine.config文件中指定的maxTimeOut值,我的machine.config文件是在以下位置(我正在为此应用使用.net 4)

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

最初没有为maxTimeOut指定任何内容,因此默认为10分钟。为了更改它,我添加了maxTimeout="00:00:10"值,如下所示:

    <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>

我已重新启动PC并运行了持续时间超过此时间的测试-但事务在10秒后似乎没有中止,而是使用了TransactionScopeOption参数中指定的scopeOption.TimeOut值(5分钟),并且该事务5分钟后超时。

我是否已将maxTimeout值包含在上方的正确位置?文件中是否需要更改?为什么未使用来自machine.config的maxTimeout的值?

谢谢

c# transactions oracle10g transactionscope msdtc
2个回答
17
投票

之所以未被选择,是因为应将maxTimeOut值放置在machine.config文件的末尾,正好在关闭配置标记之前。以这种方式完成操作后,它就会开始工作。

<configuration>
    <!-- Other configuration sections-->
    <system.transactions>
        <machineSettings maxTimeout="01:00:00" />
    </system.transactions>
</configuration> 

2
投票

尝试在32位计算机配置中设置值

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

可能是winforms设置用于x86编译。还要检查是否没有odac事务超时设置以及要设置的程序集。

© www.soinside.com 2019 - 2024. All rights reserved.