Visual Studio Add-in to get an assembly PublicKeyToken | Quisitive
Visual Studio Add-in to get an assembly PublicKeyToken
April 16, 2008
Quisitive
Follow the steps in this post to create a Visual Studio add-in tool

Often times during the course of a development project you may want to easily obtain the PublicKeyToken used to sign the assembly.

Most people will add the assembly to the GAC and then use the properties dialog to copy out the information needed to register the assembly with its complete signature.

This is especially true for modifying the web.config when doing any type of web or SharePoint development.

Follow the steps in this post to create a Visual Studio add-in tool that will show you the PublicKeyToken directly from Visual Studio.

  • In Visual Studio, select External Tools from the Tools menu.
  • In the External Tools dialog, click Add and enter Get Assembly Public Key for the Title .
  • Fill the Command textbox by browsing to sn.exe. It is typically installed at the following location: Visual Studio 2008: C:Program FilesMicrosoft Visual Studio 8SDKv2.0Binsn.exe. Visual Studio 2010: C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinsn.exe In the Arguments textbox, type the following (case sensitive) -Tp “$(TargetPath)” .
  • Enable the Use Output window checkbox.
  • Click OK .
  • The new command is added to the Tools menu.

After building the assembly, select Get Assembly Public Key from the Tools menu in Visual Studio and the PublicKeyToken will be displayed Visual Studio’s output window.