Reading Public Key Token From Assembly Not Installed in the GAC

C

Cramer

How can I programmatically read the public key token, Version, and Culture
values of an assembly that is not yet installed into the GAC, and all I have
is the assembly's containing dll file on disk?

I have searched, but the closest thing I found is the FileVersionInfo class
that lets me get at the *file* version (which isn't necessarily the
*assembly* version).

What I would like to do is programmatically look at a dll file on disk, and
somehow retrieve from it the public key token, version, and culture values
for a contained assembly (assuming it contains only one assembly would be
fine).

Thanks.
 
M

Marc Gravell

AssemblyName an = AssemblyName.GetAssemblyName(path);
Version version = an.Version;
byte[] keyToken = an.GetPublicKeyToken();
CultureInfo culture = an.CultureInfo;

Marc
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top