Thursday, June 6, 2013

What is a Public Key Token? How to find the public key token for a .NET DLL or Assembly ?

What is a Public Key Token?

A Public Key Token is something that makes your assembly unique. Every .NET assembly that you compile is signed by a private key. This private key is unique and used to identify the assembly. But this private key is  not publicly visible. Before it is publicly exposed, it is hashed into a 16 character (64-bit)  long string which is called as Public Key Token.

Snapshot below illustrates an assembly with its version and public key token.

An assembly version below .NET Framework 4.5

Where can you find globally deployed assemblies?
Assemblies are compiled in a bin directory of your application. But when they are deployed globally, they goes to a special location in your hard drive.

You can find assemblies of .NET Framework 4.0 and below at C:\Windows\assembly.
Assemblies of .NET Framework 4.5 goes to C:\Windows\Microsoft.NET\assembly.

You can find your assembly under any of these three folders depending upon the processor architecture you selected while compiling your assembly.

Snapshot below shows a .NET Framework 4.5 assembly named SampleAlertHandler.dll. Its public key token is visible in the address bar which is 33a1b5598fa37cf2.

An assembly version of  .NET Framework 4.5

There is also another way to find public key token of an assembly.
I will show an example for a .NET Framework 4.5 assembly. It can be obtained via a Visual Studio command prompt or via PowerShell. I will use command prompt for Visual Studio 2012.

If you don't know where Visual Studio 2012 command prompt is located, you can reach there my navigation menu as under.

  1. Start Menu
  2. Programs
  3. Microsoft Visual Studio 2012
  4. Visual Studio Tools
  5. Developer Command Prompt for VS2012
After reaching the command prompt screen you will have to use sn -T command followed by assembly location. For example

sn -T  "C:\Windows\Microsoft.NET\assembly\GAC_MSIL\SampleAlertHandler\v4.0_1.0.0.0__33a1b5598fa37cf2\SampleAlertHandler.dll" 

The public key token will be revealed as shown below along with its version info. 
sn - T command 







2 comments:

  1. Thank you Rica. I am glad that it helped you. Cheers.

    ReplyDelete
  2. Sharepoint Realm: What Is A Public Key Token? How To Find The Public Key Token For A .Net Dll Or Assembly ? >>>>> Download Now

    >>>>> Download Full

    Sharepoint Realm: What Is A Public Key Token? How To Find The Public Key Token For A .Net Dll Or Assembly ? >>>>> Download LINK

    >>>>> Download Now

    Sharepoint Realm: What Is A Public Key Token? How To Find The Public Key Token For A .Net Dll Or Assembly ? >>>>> Download Full

    >>>>> Download LINK zL

    ReplyDelete