Alessandro
Alessandro

Reputation: 886

Get public key tokent without loading dll

I need to get a dll public key token. I know that that is possible by loading the dll and getting that information:

Assembly.GetExecutingAssembly().GetName().GetPublicKeyToken();

Unfortunatelly I might need to change the dll during run time, so I cannot have it loaded.

Is there any way of getting that information without having to load the dll? Even by giving the actual path of the dll?

Side note: I can also get that information by using System.Diagnostics to start a process to use the utility SN to get that information, but I would like to avoid that.

Upvotes: 4

Views: 1140

Answers (1)

Alessandro
Alessandro

Reputation: 886

It is possible to get the public token without loading the asssembly by doing:

AssemblyName.GetAssemblyName("assembly-path.dll").GetPublicKeyToken();

Upvotes: 4

Related Questions