【发布时间】:2012-12-11 21:08:41
【问题描述】:
我有一个用 .NET 4.0 框架编写的 Windows 服务,它使用 NHibernate 在与 Oracle 数据库对话的分布式事务中登记。在我们的测试环境中,服务遇到数据库错误,这似乎导致 NHibernate 关闭 ADO.NET 连接出现问题。
对 NHibernate 的整个调用,从打开会话到处理它,都包装在一个捕获 System.Exception 的 try/catch 块中,但该块中没有捕获到错误。
我在下面的 Windows 事件日志中包含了堆栈跟踪以供参考。
我相信异常是在另一个线程中引发的(堆栈跟踪似乎引用了该线程),然后该线程向上传播并导致 Windows 服务崩溃。
我的问题是:
1.如果是另一个线程,它来自哪里(什么开始它)?
2. 有什么我可以添加到我的代码中以确保此异常不会逃逸并关闭 Windows 服务吗?
应用程序:X
框架版本:v4.0.30319
说明:进程因未处理的异常而终止。
异常信息:NHibernate.ADOException
堆栈:
在 NHibernate.Connection.ConnectionProvider.CloseConnection(System.Data.IDbConnection)
在 NHibernate.Connection.DriverConnectionProvider.CloseConnection(System.Data.IDbConnection)
在 NHibernate.AdoNet.ConnectionManager.CloseConnection()
在 NHibernate.AdoNet.ConnectionManager.AfterTransaction()
在 NHibernate.Impl.SessionImpl.AfterTransactionCompletion(Boolean, NHibernate.ITransaction)
在 NHibernate.Transaction.AdoNetWithDistributedTransactionFactory+c_DisplayClass1.b_0(System.Object, System.Transactions.TransactionEventArgs)
在 System.Transactions.TransactionCompletedEventHandler.Invoke(System.Object, System.Transactions.TransactionEventArgs)
在 System.Transactions.TransactionStatePromotedAborted.EnterState(System.Transactions.InternalTransaction)
在 System.Transactions.InternalTransaction.DistributedTransactionOutcome(System.Transactions.InternalTransaction, System.Transactions.TransactionStatus)
在 System.Transactions.Oletx.RealOletxTransaction.FireOutcome(System.Transactions.TransactionStatus)
在 System.Transactions.Oletx.OutcomeEnlistment.InvokeOutcomeFunction(System.Transactions.TransactionStatus)
在 System.Transactions.Oletx.OletxTransactionManager.ShimNotificationCallback(System.Object, Boolean)
在 System.Threading._ThreadPoolWaitOrTimerCallback.PerformWaitOrTimerCallback(System.Object, Boolean)
【问题讨论】:
标签: .net nhibernate windows-services distributed-transactions