DotNet Mirror
  DNM facebook   DNM Google+   DNM Twitter   

Finding the public key token value of a .Net assembly(DLL or EXE)

By Ashok Nalam on 30 Jan 2013 | Category: Visual Studio | Tagged: assembly 
  Discuss Add Comment   |  
Add rating Rate this resource   
We need the public key token of  .NET assembly(.DLLor .EXE) while registering in configuration files. The solution is very easy, by using strong name utility(sn.exe) provided by Microsoft SDK we can find the public key token.

Using sn.exe

open visual studio command prompt then go to the location where your assembly resides, then type

"c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" -T myapplicatoin.dll
If myapplicationl.dll is in D:\sampleapplication\bin\debug then the command prompt should looks like

D:\sampleapplication\bin\debug > "c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" -T myapplicatoin.dll
Hit enter button, then output will be

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

Public key token is 891468bb1a0b2ec6

other ways of getting public key token are

From GAC folder:

If the dll is registered to GAC, then you find the public token by opening the folder. It look like

Using VS External Tool:

From visual studio we can generate public key token for the current project by adding external tool. Go to visual studio -> Tools menu --> select External Tools... then a window will be opned. From the window click on Add button > provide Title as "Read Publickey Token" > select command as "c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" > write arguments as "-T $(TargetPath)" > check Use Output Window checkbox > Ok.

Now we can see "Read Publickey Token" from Tools menu > select it > from output window you can see the Publickey Token.

Note: If assembly is not registered with strong name key then by executing the above command gives you the message as ".exe/.dll does not represent a strongly named assembly"

  Discuss Add Comment    
Add rating Rate this resource   
About the Contributor
Member Since : 10 Dec 2012
Member Points (Level) : 9226  (Professional)
Location : INDIA
Home Page :
About : I am admin of this site.
Rate this resource
Add your Comment
Name Email WebSite
Captcha Refresh

Comments (0)
No comments found, click here to add comment.
cheap jordans|wholesale air max|wholesale jordans|wholesale jewelry|wholesale jerseys