I recently had some problems with the hibernate.cfg.xml
file as I hadn't had the following line in.
<property name='proxyfactory.factory_class'>NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
Now that this is fixed I get the following error.
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. (Exception from HRESULT: 0x80131040)
Why do I get this error and how do I fix it?
These files should be in the same directory as the referenced file, NHibernate.dll:
Antlr3.Runtime.dll
Iesi.Collections.dll
log4net.dll
Castle.Core.dll
Castle.DynamicProxy2.dll
Also you should add a reference or copy this one too:
As a future reference:
If your're experiencing the same issues Randy Klingelheber pointed out (dependency problems between NHibernate
and FluentNHibernate
, or any other dependent library), you can specify a redirection for the assemblies that target the old version in app.config
. This prevents one from having to recompile the dependent assembly.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" />
<bindingRedirect oldVersion="3.0.0.3001" newVersion="3.0.0.4000" />
</dependentAssembly>
</assemblyBinding>
</runtime>
This code redirects requests for the old version (3.0.0.3001 in my case) to the one actually used (3.0.0.4000). The publicKeyToken
is included in the error message.
I'm assuming you recently upgraded NHibernate to 2.1?
If so, my guess is you have different projects referencing different versions of NHibernate.
This happened to me and is harder to track down than you might think.
These are the steps I took to solve it:
That will hopefully clear up this issue for you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With