使用 NuGet 安装 NHibernate 3.2
我是 NHibernate 的新手,一直在尝试使用 NuGet 来启动和运行它、Fluent NHibernate 和 NProf。阅读本文后(http ://gurustop.net/blog/2011/03/13/nhibernate-3-1-0-on-nuget-important-details)似乎不应该直接安装v3.1,但是, v3.2 似乎没有这样的警告。
使用 NuGet 成功安装 NHibernate 3.2 和 NHibernate 后,我无法安装 Fluent NHibernate,因为它显示“已经引用较新版本的 NHibernate”。
另外,当我运行我的应用程序时,出现以下错误“无法加载文件或程序集‘NHibernate.ByteCode.Castle’或其依赖项之一”。以下链接(无法在 NHibernate 中加载文件或程序集)建议安装许多额外的程序集,这是我首先希望通过使用 NuGet 来避免的。
此时,由于 NuGet 上的包似乎不兼容,因此按照 NHForge 上的步骤启动并运行是否会更容易?
I'm new to NHibernate and have been trying to get up and running with it, Fluent NHibernate and NHProf using NuGet. After reading this article (http://gurustop.net/blog/2011/03/13/nhibernate-3-1-0-on-nuget-important-details) it seems that v3.1 shouldn't be directly installed, however, there appears no such warning for v3.2.
After successfully installing NHibernate 3.2 and NHProf using NuGet, I'm unable to install Fluent NHibernate as it says it's "Already referencing a newer version of NHibernate".
Also, when I run my app I get the following error "Could not load file or assembly 'NHibernate.ByteCode.Castle' or one of its dependencies". The following link (Could not load file or assembly in NHibernate) suggests installing a number of additional assemblies, which is what I was hoping to avoid by using NuGet in the first place.
At this point would it just be easier to follow the steps on NHForge to get things up and running as the packages on NuGet don't appear to be compatible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
NHibernate 3.2 带有自己的代理工厂。如果您使用配置文件,则只需删除 proxyfactory 配置属性。
我相信您使用的 Fluent NHibernate 版本默认使用 NHibernate.ByteCode.Castle。在这种情况下,您需要使用内置的 NHibernate 3.2 代理工厂覆盖该设置:
NHibernate 3.2 comes with its own proxy factory. If you're using a config file, you just need to remove the proxyfactory configuration property.
I believe the version of Fluent NHibernate that you're using defaults to use NHibernate.ByteCode.Castle. In that case, you would need to override that setting with the built in NHibernate 3.2 proxy factory:
Fluent NHibernate 的每个版本都使用 NHibernate 的精确版本(包含在 Fluent NHibernate 包中)
您应该删除 NHibernate 包并仅添加 Fluent NHibernate
Each version of Fluent NHibernate uses an exact version of NHibernate (included in the Fluent NHibernate package)
You should remove the NHibernate package and add only Fluent NHibernate
如果您使用 Nuget 包管理器控制台而不是 GUI 来获取包 (Install-Package FluentNHibernate),您将获得与 NHibernate 3.2 兼容的版本 1.3.0.717
我尝试过,效果很好。我已经在此链接上回答了这个问题:哪个版本的 Fluent nhibernate 与 nhibernate 3.2 兼容
If you use the Nuget Package Manager Console instead of the GUI to get the package (Install-Package FluentNHibernate) you will get version 1.3.0.717 which is compatible with NHibernate 3.2
I tried and is working fine for me. I answered this already on this link: which version of fluent nhibernate is compatible with nhibernate 3.2
我在配置文件中使用这个构造来使 FluentNhibernate 与 NHibernate 3.2 一起工作
I'm using this consctruction in config file to make FluentNhibernate work with NHibernate 3.2
NHibernate 3.2 带有自己的映射配置(Conform)。 FluentNHibernate 仅适用于 NHibernate 3.1,因此,您不能使用 3.2(我遇到了同样的问题)。因此,您必须手动下载 3.1 并引用它,除非 NuGet 允许您直接使用 3.1。
您的另一个选择是删除对 3.2 的所有引用,然后从 NuGet 安装 FluentNHibernate,然后依赖项解析器将启动并自动为您包含 NHibernate 3.1。
NHibernate 3.2 comes with its own mapping configuration (Conform). FluentNHibernate only works with NHibernate 3.1 as a result of this, you can't use 3.2 (I had the same problem). So you'll have to manually download 3.1 and reference that unless NuGet allows you to use 3.1 directly.
Your other option is to remove all references to 3.2 and then install FluentNHibernate from NuGet, then the dependency resolver will kick in and automatically include NHibernate 3.1 for you.