问题描述
这是超时设置为无限时间的超时异常的延续(而且我还看到未回答的 SqlConnection和TransactionScope超时问题).
This is continuation of Timeout exception when timeout set to infinite time (and I also see unanswered SqlConnection and TransactionScope Timeout question).
我在NHibernate,C#3.5上使用CastleProject ActiveRecord.我在TransactionScope中对数据库有多个后续插入.其中之一(随机,每次都不同)因TimeoutException而失败.无论我在配置文件中设置的超时时间(10小时),这都没有关系.如果我不使用事务作用域,它将起作用(但速度太慢).看来,NHibernate事务具有默认的超时30秒,并且不受hibernate.command_timeout值的影响.
I am using CastleProject ActiveRecord over NHibernate, C# 3.5. I have multiple subsequent inserts to a database within TransactionScope. One of them (random, different each time) fails with TimeoutException. Whichever timeout I set in my config file (10 hours), this does not matter. If I do not use transaction scope, it work (but too slow). It seems, NHibernate transaction has default timeout 30 second and is not affected by hibernate.command_timeout value.
对吗?如何克服这个问题?
Is it correct? How to overcome this?
推荐答案
您是否尝试过增加连接超时值?
Have you tried increasing your connection time out value?
在连接字符串中包括"Connection Timeout = somehighvalueinsecondshere".
Include "Connection Timeout=somehighvalueinsecondshere" in the connection string.
http://msdn.microsoft. com/en-us/library/system.data.sqlclient.sqlconnection.connectiontimeout.aspx
这篇关于使用NHibernate TransactionScope时发生超时异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!