16

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

It Grunt
  • 3,300
  • 3
  • 21
  • 35

4 Answers4

31

Use

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

or

sn -T YourAssembly.dll
Incognito
  • 16,567
  • 9
  • 52
  • 74
18

sn -Tp assembly.dll

will tell you what you need to know

cristobalito
  • 4,192
  • 1
  • 29
  • 41
5

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

MorioBoncz
  • 920
  • 11
  • 22
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"
vrqq
  • 448
  • 3
  • 8