dll versions displayed in visual studio .Net not reflecting the referenced dll file/product versions

StackOverflow https://stackoverflow.com/questions/13576604

Question

I have a console app c# project that depends on NHibernate 3.3.2 and ShapArch.NHibernate 2.0.4.628 which has been compiled with NHibernate 3.3.1 (as far as I know - I might be wrong, but when I created a 2.0.4 SharpArch project it downloaded NH 3.3.1 via Nuget ).

Why does Visual Studio show NHibernate as being version 3.3.1.4000 when the referenced dll is 3.3.2.4000? The Specific Version property is set to false for all references. And the version for SharpArch appears in VS 2.0.0.0 instead of 2.0.4 which is the file/product version.

In the app config I have:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="NHibernate" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
      <bindingRedirect oldVersion="0.0.0.0-3.3.1.4000" newVersion="3.3.2.4000" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

The app fails to load with:

System.IO.FileLoadException was unhandled
  Message=Could not load file or assembly 'NHibernate, Version=3.3.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)
  Source=MyApp.ResourcesGenerator
  FileName=NHibernate, Version=3.3.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
  FusionLog=""
  StackTrace:
       at MyApp.ResourcesGenerator.Program.InitializeNHibernateSession()
       at SharpArch.NHibernate.NHibernateInitializer.InitializeNHibernateOnce(Action initMethod) in d:\Builds\SharpArch2\Solutions\SharpArch.NHibernate\NHibernateInitializer.cs:line 54
       at MyApp.ResourcesGenerator.Program.Initialize() in C:\projects\tc\Trunk\Source_LibsUpgrade\Applications\PerformanceManagement\MyApp.ResourcesGenerator\Program.cs:line 149
       at MyApp.ResourcesGenerator.Program.Main(String[] args) in C:\projects\tc\Trunk\Source_LibsUpgrade\Applications\PerformanceManagement\MyApp.ResourcesGenerator\Program.cs:line 31
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.FileLoadException
       Message=Could not load file or assembly 'NHibernate, Version=3.3.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)
       FileName=NHibernate, Version=3.3.0.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4  

I am not even sure why it's trying to load 3.3.0.4000 when sharp architecture has been compiled with 3.3.1.

Était-ce utile?

La solution

NHibernate 3.3.2.GA has a file version of 3.3.2.4000 but the assembly version is still 3.3.1.4000. This was done to allow an upgrade of NHibernate without needing binding redirects. All future minor version upgrades of NHibernate will also follow this pattern.

So the solution for you is just to remove the binding redirect.

The confusing part here is that the Windows Explorer only shows the file and product versions but Visual Studio only shows the assembly version.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top