ASP.NET MVC 2.0 NHibernate 配置()问题
我已经为我的 ASP.NET Web 应用程序安装了 NHibernate,尽管我在以下代码行中实时遇到问题:
if (_sessionFactory == null)
{
_sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
查看内部异常,问题是这样的:
{"无法找到文件 'D:\Websites \Test\Test\Test\bin\hibernate.cfg.xml'.":"D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml"}
这是有道理的,因为该文件不存在于该文件中地点。这行代码位于我的核心项目中。文件 hibernate.cfg.xml 当前位于我的 Infrastucture 项目中,而不是我的 Core 中。应该是这样吗?我已将文件复制到此位置,但仍然遇到问题。如果我手动将文件复制到 Windows 资源管理器中的此位置,则会在运行时收到以下错误。
{“无法加载文件或程序集 “基础设施”或其之一 依赖关系。系统找不到 指定的文件。":"基础结构"}
另外,我缺少 DynamicProxy.dll,因为我正在使用 castle,并且在从 http://sourceforge.net/projects/nhibernate/
有什么建议吗?我可以在下载中看到 LinFu.DynamicProxy.dll,尽管它说我只需要 Linfu 或 Castle 之一,我正在使用 Castle 进行此实验,不确定这是否与之有关,只是认为它可能有帮助
? 詹姆斯
I have installed NHibernate for my ASP.NET web app although I'm getting a problem in real-time on the following line of code:
if (_sessionFactory == null)
{
_sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
Looking at the inner exception the problem is this:
{"Could not find file 'D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml'.":"D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml"}
This makes sense, as the file doesnt exist in that location. This line of code is within my Core project. File hibernate.cfg.xml is currently in my Infrastucture project, not my Core. Should this be? I have copied the file into this location although I still get problems. If I manually copy the file into this location within windows explorer I then get the following error during runtime.
{"Could not load file or assembly
'Infrastructure' or one of its
dependencies. The system cannot find
the file specified.":"Infrastructure"}
Also, I'm missing DynamicProxy.dll as I'm using castle and I couldnt see a version of the DynamicProxy in the castle folder that I downloaded from http://sourceforge.net/projects/nhibernate/
any suggestions? I can see LinFu.DynamicProxy.dll within the download although it says I only need one of the folders, Linfu or Castle, and I'm using Castle for this experiment. Not sure if this has anything to do with it, just thought it might help.
any ideas? Many thanks,
James
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于“无法找到 hibernate.cfg.xml”:您可以将其设置为“复制到输出”(请参阅 此) 或 将其配置为嵌入式资源。
关于“无法加载程序集基础结构”:您的 bin 中缺少基础结构.dll 或其依赖项之一,正如错误所示。
关于缺少 DynamicProxy.dll:如果您使用 NHibernate 3.x,则需要使用 Castle 字节码提供程序的是 NHibernate.ByteCode.Castle.dll 和 Castle.Core.dll
About "Could not find hibernate.cfg.xml": you can either set it to "Copy to Output" (see this) or configure it as an embedded resource.
About "Could not load assembly Infrastructure": you're missing Infrastructure.dll in your bin, or one of its dependencies, just as the error says.
About missing DynamicProxy.dll: if you're using NHibernate 3.x all you need to use the Castle bytecode provider is NHibernate.ByteCode.Castle.dll and Castle.Core.dll