Assembly version from command line?

DllVisual Studio-2010AssembliesVersion

Dll Problem Overview


Is there a Microsoft tool to get the assembly version of a DLL file from a command line?

(I know that I can code my own tool.)

Dll Solutions


Solution 1 - Dll

This is an area where PowerShell shines. If you don't already have it, install it. It's preinstalled with Windows 7.

Running this command line:

[System.Reflection.Assembly]::LoadFrom("C:\full\path\to\YourDllName.dll").GetName().Version

outputs this:

Major  Minor  Build  Revision
-----  -----  -----  --------
3      0      8      0

Note that LoadFrom returns an assembly object, so you can do pretty much anything you like. No need to write a program.

Solution 2 - Dll

If you use mono and linux, try this:

monodis --assembly MyAssembly.dll

find . -name MyAssembly.dll -exec monodis --assembly {} ';' | grep Version 

Solution 3 - Dll

For those, like I, who come looking for such a tool:

using System;
using System.IO;
using System.Reflection;

class Program
{
    public static void Main(string[] args)
    {
        foreach (string arg in args)
        {
            try
            {
                string path = Path.GetFullPath(arg);
                var assembly = Assembly.LoadFile(path);
                Console.Out.WriteLine(assembly.GetName().FullName);
            }
            catch (Exception exception)
            {
                Console.Out.WriteLine(string.Format("{0}: {1}", arg, exception.Message));
            }
        }
    }
}

Solution 4 - Dll

In Powershell

$version = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("filepath.exe").FileVersion.ToString()

Solution 5 - Dll

I used the selected answer until I got the following error Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. for several assemblies

using

[System.Reflection.Assembly]::ReflectionOnlyLoadFrom("C:\full\path\to\YourDllName.dll").GetName().Version

should work in those cases (probably all cases)

Solution 6 - Dll

Wow this is bad considering things like old exploitable gdiplus.dll's floating around.

My solution is simple. batch file programming.

This puts an nfo file in the same dir with the version

You can GET filever.exe, which can be downloaded as part of the Windows XP SP2 Support Tools package - only 4.7MB of download.

adobe_air_version.bat

c:\z\filever.exe /A /D /B "C:\Program Files\Common Files\Adobe AIR\Versions\1.0\Adobe AIR.dll" >000_adobe_air.dll_VERSION.nfo

exit

Variation.

Get all the versions in a directory to a text file.

c:\z\filever.exe /A /D /B "c:\somedirectory\ *.dll *.exe >000_file_versions.nfo

exit

There's also Sigcheck by systernals.

http://technet.microsoft.com/en-us/sysinternals/bb897441.aspx

Solution 7 - Dll

File Version tool will help:

filever /V YourDllName.dll

Solution 8 - Dll

Adding some sugar to the other powershell-ish answers...

To get extended properties like 'FullName'

$dllPath = "C:\full\path\to\YourDllName.dll";
$ass  = [System.Reflection.Assembly]::LoadFrom($dllPath);
$ass.GetName();
$ass

Solution 9 - Dll

Do you use GACUTIL?

You can get the assembly version from this command below.

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe /L "<your assembly name>"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionPatrice PezillierView Question on Stackoverflow
Solution 1 - DllOregonGhostView Answer on Stackoverflow
Solution 2 - Dllhead_thrashView Answer on Stackoverflow
Solution 3 - DllPaul RuaneView Answer on Stackoverflow
Solution 4 - DllAussie AshView Answer on Stackoverflow
Solution 5 - DllgilmishalView Answer on Stackoverflow
Solution 6 - DllTail-GunnerView Answer on Stackoverflow
Solution 7 - DllAntony ThomasView Answer on Stackoverflow
Solution 8 - DllOzBobView Answer on Stackoverflow
Solution 9 - DllRadityo ArdiView Answer on Stackoverflow