What is the simplest way to find the Public-Key-Token of an assembly?
The simplest way I can think of would be a simple right-click, get public key, but this functionality isn't there, maybe there is a Visual Studio Extension for that?
I'm using Visual Studio 2010, if an extension is available.
If you have included the assembly in your project, you can do :
In case someone was looking for the assembly Public Key (like me), not the Public Key Token - using sn.exe works great, except you have to use -Tp switch, which will return both the Public Key and Public Key Token - more at https://msdn.microsoft.com/en-us/library/office/ee539398(v=office.14).aspx .
Open a command prompt and type one of the following lines according to your Visual Studio version and Operating System Architecture :
VS 2008 on 32bit Windows :
VS 2008 on 64bit Windows :
VS 2010 on 32bit Windows :
VS 2010 on 64bit Windows :
VS 2012 on 32bit Windows :
VS 2012 on 64bit Windows :
VS 2015 on 64bit Windows :
Note that for the versions VS2012+, sn.exe application isn't anymore in bin but in a sub-folder. Also, note that for 64bit you need to specify (x86) folder.
If you prefer to use Visual Studio command prompt, just type :
where
<assemblyname>
is a full file path to the assembly you're interested in, surrounded by quotes if it has spaces.You can add this as an external tool in VS, as shown here:
http://blogs.msdn.com/b/miah/archive/2008/02/19/visual-studio-tip-get-public-key-token-for-a-stong-named-assembly.aspx
another option:
if you use PowerShell, you can find out like:
like
and will appear like
The simplest way for me is to use ILSpy.
When you drag & drop the assembly on its window and select the dropped assembly on the the left, you can see the public key token on the right side of the window.
(I also think that the newer versions will also display the public key of the signature, if you ever need that one... See here: https://github.com/icsharpcode/ILSpy/issues/610#issuecomment-111189234. Good stuff! ;))
An alternate method would be if you have decompiler, just look it up in there, they usually provide the public key. I have looked at .Net Reflector, Telerik Just Decompile and ILSpy just decompile they seem to have the public key token displayed.