从 NHibernate 迁移到 FluentNHibernate:汇编错误(与版本相关)?
不知道从哪里开始,但我已经获得了最新版本的 NHibernate,成功映射了最简单的业务对象等。当尝试迁移到 FluentNHibernate 并执行相同的操作时,我在构建时收到此错误消息:
“System.IO.FileLoadException:可以 不加载文件或程序集“NHibernate”, 版本=2.1.0.4000,文化=中立, PublicKeyToken=aa95f207798dfdb4' 或 它的依赖项之一。位于的 程序集的清单定义确实 与程序集参考不匹配。”
背景:我是 Hibernate、NHibernate 和 FluentNHibernate 的新手,但对 .NET、C# 等不熟悉。
数据库 我有一个名为 Category:
(PK) CategoryID (类型:int)的数据库表,唯一,自动递增 UserID(类型:uniqueidentifier)——给定 ASP.NET 数据库中用户 Guid 的值 标题(类型:varchar(50) - 类别的标题
涉及的组件:
- 我有一个 SessionProviderClass,它创建到数据库的映射
- 我有一个 Category 类,其中包含 FluentNHibernate 的所有虚拟方法 我
- 我有一个 CategoryMap :ClassMap 类,它对实体进行流畅的映射
- 我有一个 CategoryRepository 类,其中包含添加和保存类别的方法
- TestCatAdd.aspx 文件,它使用 CategoryRepository 类。
有 发布其中任何一个的代码,但我不确定是否有必要,因为我认为问题在于 FluentNHibernate 引用的内容和我之前安装的 NHibernate 之间存在版本冲突,
提前感谢您提供的任何帮助。给!
Not sure where to start, but I had gotten the most recent version of NHibernate, successfully mapped the most simple of business objects, etc. When trying to move to FluentNHibernate and do the same thing, I got this error message on build:
"System.IO.FileLoadException: Could
not load file or assembly 'NHibernate,
Version=2.1.0.4000, Culture=neutral,
PublicKeyToken=aa95f207798dfdb4' or
one of its dependencies. The located
assembly's manifest definition does
not match the assembly reference."
Background: I'm new to Hibernate, NHibernate, and FluentNHibernate -- but not to .NET, C#, etc.
Database
I have a database table called Category:
(PK) CategoryID (type: int), unique, auto-incrementing
UserID (type: uniqueidentifier) -- given the value of the user Guid in ASP.NET database
Title (type: varchar(50) -- the title of the category
Components involved:
- I have a SessionProviderClass which creates the mapping to the database
- I have a Category class which has all the virtual methods for FluentNHibernate to override
- I have a CategoryMap : ClassMap class, which does the fluent mappings for the entity
- I have a CategoryRepository class that contains the method to add & save the category
- I have the TestCatAdd.aspx file which uses the CategoryRepository class.
Would be happy to post code for any of those, but I'm not sure that it's necessary, as I think the issue is that somewhere there's a version conflict between what FluentNHibernate references and the NHibernate I have installed from before.
Thanks in advance for any help you can give!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不存在“从 NHibernate 迁移到 FluentNHibernate”这样的事情。
FluentNHibernate 只是 NHibernate 的一个插件,它提供了一种略有不同的创建映射的方法。
错误消息很明确:您正在使用为 NHibernate 2.1.0 编译的 FluentNHibernate 版本,并且尝试将其与 NHibernate 2.1.2 一起使用,因此版本冲突。
下载使用 NH 2.1.2 的 Fluent 版本或从源代码编译。
There is no such thing as "Moving from NHibernate to FluentNHibernate".
FluentNHibernate is just an addon for NHibernate that provides a slightly different way to create the mappings.
The error message is clear: you are using a version of FluentNHibernate compiled for NHibernate 2.1.0, and you tried to use it with NHibernate 2.1.2, hence the version conflict.
Either download a version of Fluent that uses NH 2.1.2 or compile from source.
谢谢大家,
真正的答案是删除并重新添加 FluentNHibernate 附带的程序集(包括 NHibernate 的兼容版本)。
我还必须记住添加正确的引用(例如,在使用 NHibernate 时,我没有添加对 Castle.dll 的引用等)。
但是,这发现了更多问题,我将在单独的线程中发布这些问题。
谢谢!
Thanks all,
The true answer was to remove and re-add the assemblies that came with FluentNHibernate (including the compatible version of NHibernate).
I also had to remember to add the correct references (for example, when using NHibernate, I had not added references to Castle.dll, etc.)
However, this uncovered more problems, which I'll post about in a separate thread.
Thanks!