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 functio
If the library is included in the VS project, you can check .cproj
file, e.g.:
<ItemGroup>
<Reference Include="Microsoft.Dynamic, Version=1.1.0.20, Culture=neutral, PublicKeyToken=7f709c5b713576e1, processorArchitecture=MSIL">
...
If you have included the assembly in your project, you can do :
var assemblies =
AppDomain.CurrentDomain.GetAssemblies();
foreach (var assem in assemblies)
{
Console.WriteLine(assem.FullName);
}
Another options is to use the open source tool NuGet Package Explorer for this.
From a Nuget package (.nupkg) you could check the PublicKeyToken, or drag the binary (.dll) in the tool. For the latter select first "File -> new"
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! ;))
You can use the Ildasm.exe (IL Disassembler) to examine the assembly's metadata, which contains the fully qualified name.
Following MSDN: https://msdn.microsoft.com/en-us/library/2exyydhb(v=vs.110).aspx
another option:
if you use PowerShell, you can find out like:
PS C:\Users\Pravat> ([system.reflection.assembly]::loadfile("C:\Program Files (x86)\MySQL\Connector NET 6.6.5\Assemblies\v4.0\MySql.Data.dll")).FullName
like
PS C:\Users\Pravat> ([system.reflection.assembly]::loadfile("dll full path")).FullName
and will appear like
MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d