linq - NHibernate、NHibernate.Linq 和 FluentNHibernate? throw 错误

标签 linq nhibernate fluent-nhibernate

我在上一个问题中遇到以下错误:

Fluent NHibernate? Am I doing this correctly?

但是,现在,当我调用该函数时:

LoginRepository login = new LoginRepository();
var allLogins = login.GetAllLogins().ToList();

它抛出一个错误:

Could not load file or assembly 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

问题的根源是 NHibernate.Linq。 FusionLog如下:

=== Pre-bind state information ===
LOG: User = Sean
LOG: DisplayName = NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4 (Fully-specified)
LOG: Appbase = file:///C:/Development/DefaultCollection/Sandboxes/Sean/NHibernateExample/NHibernateExample/
LOG: Initial PrivatePath = C:\Development\DefaultCollection\Sandboxes\Sean\NHibernateExample\NHibernateExample\bin
Calling assembly : NHibernate.Linq, Version=1.1.0.1001, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Development\DefaultCollection\Sandboxes\Sean\NHibernateExample\NHibernateExample\web.config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d33a79ac/1e32c532/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d33a79ac/1e32c532/NHibernate/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/Development/DefaultCollection/Sandboxes/Sean/NHibernateExample/NHibernateExample/bin/NHibernate.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我使用 NuGet 获取最新版本的 NHibernate、NHibernate.Linq 和 FluentNHibernate。

有人能引导我走向正确的方向吗?

再次感谢!

最佳答案

您应该运行兼容包,您的NHibernate版本是2.1.2.4,这不是最新的。

首先添加对 NHibernate 3.0 的引用,据我所知,NHibernate.Linq 已过时,因为它属于版本 2,而在版本 3.0 中,Linq 功能位于 NHibernate 程序集本身中

关于linq - NHibernate、NHibernate.Linq 和 FluentNHibernate? throw 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5645250/

相关文章:

visual-studio-2010 - 无法加载文件或程序集 'NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'

nhibernate - NH3.2 使用 'where' 子句按代码映射

c# - 使用 Linq 还是不使用 Linq - 哪个版本更漂亮?

c# - foreach 循环为 mvc View 中的所有帖子显示相同的图像

.net - 带SQL后端的新.net Web应用程序的mybatis.net或nhibernate

nhibernate - 使用一个连接而不是两个连接进行查询

nhibernate - 流畅的NHibernate问题

c# - 在安装时更改 app.config

c# - LINQ 运算符和 LINQ 关键字之间的区别

sql-server - 在数据库级别设置 NOCOUNT OFF?