56

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
  • 153,850
  • 22
  • 249
  • 325
user3229570
  • 853
  • 2
  • 10
  • 23
  • 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
  • 3
    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

5 Answers5

76

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
  • 153,850
  • 22
  • 249
  • 325
8

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
  • 8,408
  • 6
  • 48
  • 68
  • 7
    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
  • 1
    @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
3

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

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

var version = 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

meJustAndrew
  • 6,011
  • 8
  • 50
  • 76
Michael Freidgeim
  • 26,542
  • 16
  • 152
  • 170
2

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

Further details here on MSDN.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
James Lucas
  • 2,452
  • 10
  • 15
2

From Powershell (PSCore): $assembly = [System.Reflection.Assembly]::LoadFrom("$pwd\System.Memory.dll") Besides $assembly.FullName you can pick up any other prop from the object.

dbardakov
  • 651
  • 1
  • 8
  • 22
  • This approach silently gives the wrong answer if a DLL with the same name but in a different folder happens to be loaded already by the PowerShell process. In that case, it gives the assembly version of the already loaded DLL. – Edward Brey May 12 '23 at 17:33