For many reasons, I often need the PublicKeyToken of a signed assembly, such as creating custom controls or working with a product like SharePoint. Typically this information ends up in a .config file, but in my case I’m exploring Custom Data Generators for Visual Studio 2010 and need this info for an XML file Visual Studio uses. In the past, I’ve always used Reflector to figure out the PublicKeyToken. But in reading the MSDN docs about Custom Data Generators, I stumbled upon a way to do it right in Visual Studio from the Command Window.
Open a Command Window (View menu –> Other Windows –> Command Window). At the prompt type something like this:
where the path is obviously the path to your own DLL (like C:\Users\dtruxall\Documents\Visual Studio 2010\Projects\DemoGenerator\DemoGenerator\bin\Debug\DemoGenerator.dll). If you get the path correct, the Command Window gives output like this:
“DemoGenerator, Version=220.127.116.11, Culture=neutral, PublicKeyToken=22402068dd2dab84”
That’s exactly what I need for my XML.