2

I had the following error at previous question:

Fluent NHibernate? Am I doing this correctly?

But, now, when I call the function:

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

It throws an error of:

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)

The source of the problem is NHibernate.Linq. The FusionLog is as follows:

=== 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.

I used NuGet to get the latest versions of NHibernate, NHibernate.Linq, and FluentNHibernate.

Can anyone lead me in the right direction?

Thanks again!

Community
  • 1
  • 1
Sean
  • 2,496
  • 7
  • 32
  • 60

1 Answers1

3

You should run the compatible package, your NHibernate version is 2.1.2.4 which is not the latest one.

First add reference to NHibernate 3.0 , and the NHibernate.Linq is obselete AFAIK, cause it's belong to version 2 and in version 3.0 the Linq functionalitys is in NHibernate assembly itself

Jahan Zinedine
  • 14,616
  • 5
  • 46
  • 70
  • I use to call session.Linq to pass, how would you accomplish this now if NHIbernate.Linq is obselete? – Sean Apr 13 '11 at 06:46
  • 1
    http://theminimalistdeveloper.com/2010/11/20/how-to-use-fluent-nhibernate-linq-and-sqlite-in-asp-net-mvc-3-project/ – Jahan Zinedine Apr 13 '11 at 06:50
  • 2
    NHibernate 3.0 has a built-in Linq provider. http://www.tikalk.com/net/query-database-with-nhibernate-30 – Jahan Zinedine Apr 13 '11 at 06:50
  • Thank you. I guess NuGet packages are getting the latest versions. :( All these comments worked for me. Thanks! – Sean Apr 13 '11 at 07:04