NHibernate的例外:事务未连接,或者断开连接 [英] NHibernate exception: Transaction not connected, or was disconnected

查看:1364
本文介绍了NHibernate的例外:事务未连接,或者断开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的开发环境中的所有ASP.NET应用程序的工作就好了。然而,当我部署在测试机上的网站,在一些网页上我得到这个异​​常:

In our develop environment all the ASP.NET application works just fine. However, when I deploy the site on the test machine, on some pages I get this exception:

NHibernate.TransactionException: Transaction not connected, or was disconnected
   at NHibernate.Transaction.AdoTransaction.CheckNotZombied() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs:line 406
   at NHibernate.Transaction.AdoTransaction.Rollback() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Transaction\AdoTransaction.cs:line 240

我对如何解决这个问题,不知道。唯一的区别是DB的版本:
开发:10.0.5500(2008 R2,SP1,防爆preSS)
测试:10.0.5500(2008,SP3)

I have no idea on how to solve this issue. The only difference are the DB versions: Develop: 10.0.5500 (2008 R2, SP1, Express) Test: 10.0.5500 (2008, SP3)

是否有人有一个想法是怎么回事呢?

Does someone has an idea what is going on here?

推荐答案

有一个与您的session-per-request模式实现的一个问题。 ASP.NET是多线程和当线程终止请求结束时,而不是在会话被关闭。有许多<一个href=\"http://lozanotek.com/blog/archive/2009/02/17/Contextual_Sessions_with_NHibernate_ndash_Part_1.aspx\"相对=nofollow> 如何管理的session-per-要求和NHibernate有一个内置的的 NHibernate.Context.WebSessionContext 但我preFER使用依赖注入框架如的 Ninject

There's a problem with your session-per-request pattern implementation. ASP.NET is multi-threaded and the session is being closed when a thread terminates instead of when the request ends. There are many examples of how to manage session-per-request and NHibernate has a built in NHibernate.Context.WebSessionContext but I prefer to use a dependency injection framework such as Ninject.

这篇关于NHibernate的例外:事务未连接,或者断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆