Alex Rivera | Logout

How do I get the version of an assembly without loading it?

Asked 2008-10-09T16:13:11.917
28

One small function of a large program examines assemblies in a folder and replaces out-of-date assemblies with the latest versions. To accomplish this, it needs to read the version numbers of the existing assembly files without actually loading those assemblies into the executing process.

Edit
Report

1 Answer

14

Depending on the files, one option might be FileVersionInfo - i.e.

FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(path)
string ver = fvi.FileVersion;

The problem is that this depends on the code having the [AssemblyFileVersion] attribute, and it matching the [AssemblyVersion] attribute.

I think I'd look at the AssemblyName options suggested by others first, though.

answered 2008-10-09T16:23:37.887

Your Answer