NHibernate Session 和 HttpModule 实现中的错误

发布于 2024-10-10 18:05:32 字数 917 浏览 3 评论 0原文

您好,很高兴成为社区的新成员,提前感谢您的帮助。

我开始在我的项目中使用 NHibernate,这很有趣。我发现这个示例是我设法使用 Visual Studio 2005、Asp.net 和 NHibernate-2.0.1.GA 版本的 NHibernate 二进制文件来完成的。

NHibernate 基础(示例 1): www.codegod.de/WebAppCodeGod/NHibernate-Tutorial-1---and-ASP-NET-AID25.aspx

我想进一步发展并为我的项目实施良好的实践,所以我寻找更好的实现并发现了这个:

NHibernate最佳实践(示例 2): www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx?msg=3043520

所以现在我尝试仅使用 BasicSample.Data.NHibernateSessionManager.cs (作为库类)和 NHibernateSessionModule.cs 更改基本示例项目(作为 Web App_Code 中的类)这两个类都在第二个示例中提供,现在我在 NHibernateSessionManager.cs 类上收到一条错误消息:

session=session.OpenSession() “对象引用未设置为对象

如果您想检查项目源代码,请在此处

我想获得有关此错误的一些帮助,但如果你们能建议我一个最佳实践模式来管理 NHibernate 的 Session 及其 HttpModule(已实现、可供使用并发布在某处),也许会更实用。

感谢您为我提供有关此问题的见解。

Hello is nice to be a new member of the community and thanks for your help in advance.

I am starting to use NHibernate for my projects and is interesting. I found this sample that i managed to make work using Visual Studio 2005, Asp.net and the NHibernate binaries of the NHibernate-2.0.1.GA version.

NHibernate basic (Sample 1):
www.codegod.de/WebAppCodeGod/NHibernate-Tutorial-1---and-ASP-NET-AID25.aspx

I wanted to move further and implement good practices for my projects so i looked up for a better implementation and found this:

NHibernate Best Practices (Sample 2):
www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx?msg=3043520

So now I am trying to change a bit the basic sample project using only the BasicSample.Data.NHibernateSessionManager.cs (as a library class) and NHibernateSessionModule.cs (as a class in Web App_Code) both classes are provided on the second sample and now I am getting an error message on the class NHibernateSessionManager.cs :

session=session.OpenSession() "Object Reference not set as an instance of the object"

The project source in case you want to check it is here

I would like to get some help about this error, but maybe would be more practical if you guys could suggest me a best practice pattern to manage the Session and its HttpModule for NHibernate that is implemented, ready to use and posted somewhere.

Thanks for the insight you could give me about this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谢绝鈎搭 2024-10-17 18:05:32

购买这本书NHibernate 3.0 Cookbook,您可以获得以下版本的 PDF 版本:大约16英镑,讨价还价!

购买这本书,因为它介绍了如何
使用 asp.net 和 asp.net MVC 设置一个网站,展示如何实现模块
会话管理。你
不会失望的,只需 16 英镑,您就可以节省很多时间。

它基于版本 3,但会话管理与 NHibernate 2 相同。

进一步说明,我使用 Nhibernate 已经一年多了,发现很难查看博客、教程和示例应用程序等。因为有一个网上有很多关于 NHibernate 的信息,我发现很多现在已经过时了,你会发现很多矛盾和代码根本不起作用。

Buy the book NHibernate 3.0 Cookbook, You can get just the PDF for about 16 quid, BARGIN!

Buy the book as it goes through how to
set up a website using asp.net and asp.net MVC showing how to implement modules for
session management. You
will not be disappointed and for 16 quid you will save alot of time.

It is based on version 3 but the session management is the same for NHibernate 2.

As a further note I have been usuing Nhibernate for just over a year and found it hard going looking at blogs, tutorials and sample apps etc. Because there is a lot of information regarding NHibernate on the web I found a lot of it is now outdated, you find a lot of contradictions and code that just does not work.

久光 2024-10-17 18:05:32

codeproject 文章中的代码非常好,我经常使用它来了解如何为 NH 设置会话工厂。

我没有尝试您的代码,但您应该尝试按原样运行他们的示例,看看这是否适合您,然后开始使用它。

祝你好运

The code from the codeproject article is very good and I have used it a lot to learn about setting up a Session factory for NH.

I did not try your code but you should try running their sample exactly as it is, see if that works for you and then start playing with it around.

Good luck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文