17

Does anyone know of a way to view the public key token on a DLL? I'm investigating a possible mismatch between what is expected in code and what is being built.

Thanks in advance, It Grunt

4 Answers 4

31

Use

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

or

sn -T YourAssembly.dll
18

sn -Tp assembly.dll

will tell you what you need to know

1
  • Thanks!! I got exactly what I was looking for! You get the approval for getting the first post in!
    – It Grunt
    Commented Aug 25, 2010 at 19:08
5

I started using ILSpy, alternative for Reflector.NET. After opening dll, you can view public key token, version and more.

0

For DLL without .Net, using pktextract to get publicKeyToken
https://learn.microsoft.com/en-us/windows/win32/sbscs/pktextract-exe

Step1. extract .cer from dll
Right click the file, select 'Properties' then 'Digital Signatures', you may see the certificate inside.
Then select one and choose 'View Certificate' -> 'Details' -> 'Copy to File'.

Step2. We assume the file is 'D:\test.cer', then using this tool to get the publicKeyToken.

C:\> pktextract D:\test.cer
Microsoft (R) Side-By-Side Public Key Token Extractor
Copyright (C) Microsoft Corporation. All Rights Reserved

Certificate: "my-Test" - 2048 bits long
        publicKeyToken="ea1b32b5bee7776f"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.