Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 430
costa Avatar asked Nov 27 '12 02:11

costa


People also ask

How do I change the DLL Version number in Visual Studio?

For a file that is missing version info completely: After opening the DLL in Visual Studio, go to Edit > Add Resource > Version and click New. Then in the new Version tab, change FILEVERSION and PRODUCTVERSION, CompanyName, etc. Save the files and you're all set!

How do I find a DLL Version?

If you reference the dll in Visual Studio right click it (in ProjectName/References folder) and select "Properties" you have "Version" and "Runtime Version" there. In File Explorer when you right click the dll file and select properties there is a "File Version" and "Product Version" there.


1 Answers

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.

like image 120
cremor Avatar answered Sep 22 '22 12:09

cremor