Migrating from NHiberate 5.2.7 to 5.3.5 results in could not load assembly exception
Eckii24 opened this issue · 3 comments
We try to migrate the following dependencies of our project:
- NHibernate: 5.2.7 --> 5.3.5
- Nhibernate.Caches.SysCache: 5.6.0 --> 5.7.0
This results in the exception below:
NHibernate.HibernateException : could not instantiate CacheProvider: NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache
----> System.IO.FileLoadException : Could not load file or assembly 'NHibernate, Version=5.2.0.0, 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)
TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
at NHibernate.Cfg.SettingsFactory.CreateCacheProvider(IDictionary`2 properties)
at NHibernate.Cfg.SettingsFactory.BuildSettings(IDictionary`2 properties)
at NHibernate.Cfg.Configuration.BuildSettings()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
We have checked the output directory bin
for the dependencies. The corresponding assemblies are included here.
It seems that NHibernate.Caches.SysCache
does not recognize NHibernate
version 5.3.5 as a version greater than 5.2.0.0
.
Additional information:
Inside the hibernate-configuration
we have specified the property cache.provider_class
with the value NHibernate.Caches.SysCache.SysCacheProvider, NHibernate.Caches.SysCache
.
How can we solve this issue?
Thanks in advance!
Have you tried bindings redirects?
Thanks for your reply!
As a workaround your advice works. The follow code results in a successful build:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NHibernate" culture="neutral" publicKeyToken="aa95f207798dfdb4" />
<bindingRedirect newVersion="5.3.0.0" oldVersion="0.0.0.0-5.3.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime
One further question: When do you plan to support version 5.3 natively?
We avoid forcing consumer to upgrade dependencies by upgrading it in the cache project, unless we need to use something not available with previous versions.
So usually, we upgrade the nhibernate dependency on major releases.