46

I have c# application and when I made a change, I am getting the error message:

An unhandled exception of type 'System.TypeLoadException' occurred in WindowsFormsApplication1.exe

Additional information: Could not load type
'TradeIdeas.TIProData.OddsMakerColumnConfiguration' from assembly 'TIProData, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null’.

This message says the version number of dll (TIProData) is 1.0.0.0. I think there is a later version available. How can I tell the version number of a dll on my machine?

Patrick Hofman
  • 148,824
  • 21
  • 237
  • 306
user3229570
  • 743
  • 2
  • 8
  • 21
  • RIght click on the DLL go to Properties > Details. Version 1.0.0.0 Looks like its a development version of the DLL – Alex Anderson Apr 21 '15 at 12:22
  • 2
    That is the file version, not the assembly version @AlexAnderson – Patrick Hofman Apr 21 '15 at 12:22
  • Open csproj file in text editor and find that dll reference, you can change version there, seems there is 1.0.0.0 hard coded – sll Apr 21 '15 at 12:23
  • See powershell commands in https://stackoverflow.com/questions/3267009/get-file-version-and-assembly-version-of-dll-files-in-the-current-directory-and – Michael Freidgeim May 31 '22 at 21:01
  • Does this answer your question? [How can I get the assembly file version](https://stackoverflow.com/questions/909555/how-can-i-get-the-assembly-file-version) – Michael Freidgeim May 31 '22 at 21:06

4 Answers4

68

You can use Reflector, ILDASM or ILSpy to get the assembly version.

You usually can find ILDASM in C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\ildasm.exe (where v8.1A is the version of the Windows SDK installed).

ILDASM:

ildasm

Reflector:

reflector

Patrick Hofman
  • 148,824
  • 21
  • 237
  • 306
7

There is a couple of ways to do it:

  • 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.

  • Alternatively, investigate it in code:

    Assembly assembly = Assembly.LoadFrom("TestAssembly.dll");
    Version ver = assembly.GetName().Version;
    
PiotrWolkowski
  • 7,942
  • 6
  • 43
  • 65
  • 6
    Caution - the "FileVersion" shown in the properties tab is NOT the same thing as AssemblyVersion which is the id used for binding redirects or assembly loading. – NeilMacMullen Apr 22 '21 at 08:27
  • @NeilMacMullen Yes! This has bitten me a few times. A workaround I found is to open the DLL with 7-zip and read the Assembly Version from .rsrc/version.txt . Baffles me why this isn't displayed in the File Properties dialog along with the rest of it. – JuSTMOnIcAjUSTmONiCAJusTMoNICa May 31 '22 at 16:49
2

You can use AssemblyName.GetAssemblyName(string path) from a little util app.

Further details here on MSDN.

Patrick Hofman
  • 148,824
  • 21
  • 237
  • 306
James Lucas
  • 2,414
  • 9
  • 15
2

If you know Class, that belongs to assembly, you can use GetTypeInfo

var runtimeVersion = typeof(MyClass)
.GetTypeInfo()
.Assembly
.GetCustomAttribute<AssemblyFileVersionAttribute>();

String ver=RuntimeVersion.Version;  

The example is for .Net Core from https://developers.de/blogs/damir_dobric/archive/2017/06/27/how-to-deal-with-assembly-version-in-net-core.aspx

Michael Freidgeim
  • 23,917
  • 16
  • 136
  • 163