Programmatically get the version number of a DLL

JL. picture JL. · Nov 18, 2009 · Viewed 116.8k times · Source

Is it possible to get the version number programmatically from any .NET DLL?

If yes, how?

Answer

Ben Anderson picture Ben Anderson · Jan 30, 2013

This works if the dll is .net or Win32. Reflection methods only work if the dll is .net. Also, if you use reflection, you have the overhead of loading the whole dll into memory. The below method does not load the assembly into memory.

// Get the file version.
FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"C:\MyAssembly.dll");

// Print the file name and version number.
Console.WriteLine("File: " + myFileVersionInfo.FileDescription + '\n' +
                  "Version number: " + myFileVersionInfo.FileVersion);

From: http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo.fileversion.aspx

original source