Find PublicKeyToken easily

Posted on 10/8/2011 @ 6:18 AM in #Vanilla .NET by | Feedback | 1339 views

This tip will make it easy for you to get that assembly name right within Visual Studio.
This applies to both SP2010 and SP2007 or General .NET.

  1. In Visual Studio, Go to Tools –>  External Tools.
  2. Click on “Add” to add a tool, and put in the following values:
    1. Title: S&trong Name
    2. Command: Powershell.exe
    3. Arguments: -command "[System.Reflection.AssemblyName]::GetAssemblyName(\"$(TargetPath)\").FullName"
    4. Check “Use Output Window”
    5. Uncheck everything else – here’s how it should look -

3. That’s it, now in your project, Visit Tools –> Strong Name, and in the output window, itwill give you the assembly name like this –>

SandBoxWebPartWithProxy, Version=1.0.0.0, Culture=neutral, PublicKeyToken=64b818b3ff69ccfa

Sound off but keep it civil:

Older comments..


On 10/8/2011 3:28:43 PM @SPJeff said ..
Looking up the full name has always been tedious. Thanks for posting this tip! I've added it to both of my DEV virtual machines.


On 11/2/2011 9:12:17 AM Morten said ..
Hi, I get the following error when I try to execute this cool tip :(

Exception calling "GetAssemblyName" with "1" argument(s): "Could not load file


or assembly 'path.Project.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."


At line:1 char:50


+ [System.Reflection.AssemblyName]::GetAssemblyName <<<< ("path\Project\obj\Debug\Project.dll").FullName


+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException


+ FullyQualifiedErrorId : DotNetMethodException


On 1/20/2012 4:53:10 AM Adam Carr said ..
The reason you are getting that error message is that PowerShell doesn't run in .NET4 by default. So in this instance this will only work with .Net 2 to 3.5 assemblies.

You can change the PowerShell config file to switch between .Net 4 but that means you can use the command against older .Net assemblies.

http://stackoverflow.com/questions/2094694/how-can-i-run-powershell-with-the-net-4-runtime