It Grunt
It Grunt

Reputation: 3378

How to view public key tokens on DLL's

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

Upvotes: 17

Views: 13397

Answers (4)

vrqq
vrqq

Reputation: 566

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"

Upvotes: 0

MorioBoncz
MorioBoncz

Reputation: 920

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

Upvotes: 5

Incognito
Incognito

Reputation: 16577

Use

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

or

sn -T YourAssembly.dll

Upvotes: 31

cristobalito
cristobalito

Reputation: 4282

sn -Tp assembly.dll

will tell you what you need to know

Upvotes: 18

Related Questions