Skip to content

Get the PublicKeyToken of an assembly

December 2, 2010

If you don’t have any 3rd party tool or VS addon installed and you can’t add your dll to the GAC, probably the easiest way to get the public key token of an assembly is using the .NET Framework’s strong name utility, the sn.exe.

1. Open a Visual Studio command prompt (All Programs/Microsoft Visual Studio 2010\Visual Studio Tools\Visual Studio Command Prompt (2010))

2. Type: sn.exe -T <yourassembly.dll>

3. You get the Public key token:

C:\Windows\system32>sn -T yourassembly.dll

Microsoft (R) .NET Framework Strong Name Utility  Version 4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Public key token is 31bf3856ad364e35

 Make sure you use a capital T in the command option, otherwise you will probably see an error like this:

Failed to convert key to token — The public key for assembly ‘(null)’ was invalid.

Advertisements

From → .NET

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: