Sid’s Blog

(life => life.make_it_better)

How to get version or product details from a .dll file or running application?

| Comments

I came across a scenario where I had to access some information from a file with .dll extension. And then I thought to write this post. This information may include that assembly’s product name, product version, file version etc. This scenario may be required either to read a .dll file from disk or from the current running application. The code below covers both the scenarios:

1
2
3
4
5
6
7
8
9
10
11
// From executing application.
string assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

// From a physical file, provide full path to that file.
string assemblyVersion = Assembly.LoadFile('your assembly file').GetName().Version.ToString();

// From executing application, gives file version.
string fileVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion;

// From executing application, gives product version.
string productVersion = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion;

Comments