Friday, March 27, 2009

Find PublicKeyToken of signed assembly

To find the publickeytoken of an assembly, I use to drag and drop the assembly to C:\Windows\Assembly folder and then view the properties.

The better way is to use SN.EXE located under “C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin” folder.

You could integrate this tool into VS IDE using external tool features.

  1. In Visual Studio 2005, click Tools -> External Tools...
  2. Click Add and enter the following into the different fields as displayed in the following screenshot:
    • Title: Get Public Key
    • Command: C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe
    • Arguments: -Tp "$(TargetPath)"
    • Uncheck all options, except Use Output window\

Now, you have a new entry listed in the Tools menu titled Get Public Key as shown in the following screenshot:

image

 

 

 

 

Assuming you have a project open that has been configured to be signed when built, and you've built it at least one time, selecting the new Get Public Key menu item from the Tools window to get the public key token and blob in the Output window.

image 

 

 

 

Here you have assembly publictokenkey in second entry

2 comments:

Anonymous said...

Thanks sanjay ... its really nice of you for this post... it saved me a lot of time for finding the help.'

Anonymous said...

For Visual Studio 2010 the path to SN.exe is different

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe