最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

.net - NHibernate.dll 5.5.2 can not be loaded - Stack Overflow

programmeradmin3浏览0评论

I don't understand the following behaviour:

We referenced the newest NHibernate.dll 5.5.2 with Nuget into our .NET Framework 4.8 web application project. We also use the newest RtMemoryCache.dll 5.9.0 which is compatible with NHibernate 5.5.2.

There are no other versions installed anywhere else (GAC, Temporary ASP.NET Files, ...).

a) Without assembly-binding in web.config the following error occurs:

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)

=== Pre-bind state information ===
LOG: DisplayName = NHibernate, Version=5.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
(Fully-specified)
LOG: Appbase = file:///C:/Users/msvoigt/source/repos/argos/Dev/Projects/WebInterface/
LOG: Initial PrivatePath = C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\bin
Calling assembly : NHibernate.Caches.RtMemoryCache, Version=5.9.0.0, Culture=neutral, PublicKeyToken=6876f2ea66c9f443.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: NHibernate, Version=5.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/visit/fe972717/e7d5297/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/visit/fe972717/e7d5297/NHibernate/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/Users/msvoigt/source/repos/argos/Dev/Projects/WebInterface/bin/NHibernate.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

b) With the following assembly-binding in web.config ...

<dependentAssembly>
 <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
 <bindingRedirect oldVersion="0.0.0.0-5.5.2.0" newVersion="5.5.2.0" />
</dependentAssembly>

...the following error occurs:

Could not load file or assembly 'NHibernate, Version=5.5.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)

=== Pre-bind state information ===
LOG: DisplayName = NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
(Fully-specified)
LOG: Appbase = file:///C:/Users/msvoigt/source/repos/argos/Dev/Projects/WebInterface/
LOG: Initial PrivatePath = C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\bin
Calling assembly : Persistent.Interfaces, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 5.5.0.0 redirected to 5.5.2.0.
LOG: Post-policy reference: NHibernate, Version=5.5.2.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: The same bind was seen before, and was failed with hr = 0x80131040.

Persistent.Interfaces references 5.5.2 as well.

c) With the following assembly-binding in web.config it works:

<dependentAssembly>
 <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
 <bindingRedirect oldVersion="0.0.0.0-5.5.2.0" newVersion="5.5.0.0" />
</dependentAssembly>

But I don't understand why and I am not a fan of using stuff which I don't understand.

Can anyone help here? My fav solution would be if we could remove the assembly binding completely.

Thank you!

I don't understand the following behaviour:

We referenced the newest NHibernate.dll 5.5.2 with Nuget into our .NET Framework 4.8 web application project. We also use the newest RtMemoryCache.dll 5.9.0 which is compatible with NHibernate 5.5.2.

There are no other versions installed anywhere else (GAC, Temporary ASP.NET Files, ...).

a) Without assembly-binding in web.config the following error occurs:

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)

=== Pre-bind state information ===
LOG: DisplayName = NHibernate, Version=5.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
(Fully-specified)
LOG: Appbase = file:///C:/Users/msvoigt/source/repos/argos/Dev/Projects/WebInterface/
LOG: Initial PrivatePath = C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\bin
Calling assembly : NHibernate.Caches.RtMemoryCache, Version=5.9.0.0, Culture=neutral, PublicKeyToken=6876f2ea66c9f443.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: NHibernate, Version=5.2.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/visit/fe972717/e7d5297/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/visit/fe972717/e7d5297/NHibernate/NHibernate.DLL.
LOG: Attempting download of new URL file:///C:/Users/msvoigt/source/repos/argos/Dev/Projects/WebInterface/bin/NHibernate.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

b) With the following assembly-binding in web.config ...

<dependentAssembly>
 <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
 <bindingRedirect oldVersion="0.0.0.0-5.5.2.0" newVersion="5.5.2.0" />
</dependentAssembly>

...the following error occurs:

Could not load file or assembly 'NHibernate, Version=5.5.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)

=== Pre-bind state information ===
LOG: DisplayName = NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
(Fully-specified)
LOG: Appbase = file:///C:/Users/msvoigt/source/repos/argos/Dev/Projects/WebInterface/
LOG: Initial PrivatePath = C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\bin
Calling assembly : Persistent.Interfaces, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\msvoigt\source\repos\argos\Dev\Projects\WebInterface\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Redirect found in application configuration file: 5.5.0.0 redirected to 5.5.2.0.
LOG: Post-policy reference: NHibernate, Version=5.5.2.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
LOG: The same bind was seen before, and was failed with hr = 0x80131040.

Persistent.Interfaces references 5.5.2 as well.

c) With the following assembly-binding in web.config it works:

<dependentAssembly>
 <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
 <bindingRedirect oldVersion="0.0.0.0-5.5.2.0" newVersion="5.5.0.0" />
</dependentAssembly>

But I don't understand why and I am not a fan of using stuff which I don't understand.

Can anyone help here? My fav solution would be if we could remove the assembly binding completely.

Thank you!

Share Improve this question asked Nov 20, 2024 at 8:13 PowerslavePowerslave 4672 gold badges9 silver badges29 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0 +50

For binary compatibility reasons build is not included in NHibernate assembly version (so in theory you can simply update 5.5 assemblies in app without recompilation)

So all NHibernate 5.5 versions have the same assembly version: 5.5.0.0

Most details are present in error message:

Could not load file or assembly 'NHibernate, Version=5.5.0.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4'... The located assembly's manifest definition does not match the assembly reference.

So .NET found NHibernate assembly with version 5.5.0.0 but fails to load it due to redirect rules:

LOG: Redirect found in application configuration file: 5.5.0.0 redirected to 5.5.2.0.
LOG: Post-policy reference: NHibernate, Version=5.5.2.0, Culture=neutral, PublicKeyToken=aa95f207798dfdb4

My fav solution would be if we could remove the assembly binding completely.

Not possible with strong name assemblies.

发布评论

评论列表(0)

  1. 暂无评论