Freigeben über


How to get your PublicKeyToken?

Say you've signed your assembly with a strong name, and you need to get the information about the PublicKeyToken. Now there are many tools available out there that gets you this info such as the .NET Reflector. However if you are too lazy to download a utility to help you do this, there is a quick and easy way to punch a few commands at the command prompt to reveal your public key token. These are the few easy steps to do so.

  1. Go to your project folder. In Solution Explorer, go to the properties of your project, and copy your Project Folder into the clipboard.
  2. Open up Visual Studio 2005 Command Prompt. Type cd followed by pasting your recent clipboard content onto the command prompt. You have do right-mouse click on your command prompt window to paste.
  3. Go to the folder which stores your assembly. Most likely it is in bin\debug, by default.
  4. gacutil -i AssemblyName.dll
  5. gacutil -l AssemblyName
  6. Right-mouse click the command prompt area, copy the publickeytoken info. Example:PublicKeyToken=b03f5f7f11d50a3a
  7. Remember to remove the assembly as you do not want to install it in the global assembly cache. Remove by doing gacutil -u AssemblyName
  8. VOILA!

Comments

  • Anonymous
    November 15, 2006
    How about: sn.exe -T <assembly>

  • Anonymous
    September 22, 2010
    Patrick's suggestion works fine for my case. Thanks. "C:Program FilesMicrosoft Visual Studio 8SDKv2.0Binsn.exe" -T MyAssemblyName.dll