Udostępnij za pośrednictwem


Quick Tip: Find the Four-Part Name for an Assembly

When developing for SharePoint, you sometimes need to find the four-part name for an assembly. You can do this inside of Visual Studio 2010 using PowerShell. It’s pretty straight-forward.

  1. In the Tools menu of Visual Studio, click External Tools.
    Tools Menu
  2. In the dialog, click Add to get a new tool.
    External Tools Menu
  3. Now, configure the tool with the following options:
    Title: Get Four-Part Name
    Command: powershell.exe
    Arguments: –command "[System.Reflection.AssemblyName]::GetAssemblyName(\"$(TargetPath)\").FullName
    Use Output window: Checked
    image
  4. Click OK to dismiss the window.

Now, you can go into the Tools menu to see your tool. If you click it, it will print out the four-part name including the public key token in your Output window.

image

Comments

  • Anonymous
    November 05, 2010
    I always wondered what the easiest way to do this was.  Good tip!

  • Anonymous
    December 13, 2010
    Works beautifully.  I keep getting "null" for my PublicKeyToken however.  I'm new to developing for Sharepoint, could you point me in the right direction? Thanks for the great tip.

  • Anonymous
    December 14, 2010
    @Bob, I'm glad you enjoyed the tip! Keep an eye out for more tips in the future. @Doug, have you built the project? It may not have a DLL to run the command against, so you'll get null back. Also, make sure you update your bookmarks to blogs.msdn.com/.../sharepointdev for our new blog! You'll see more tips about SharePoint development there. :) -Dallas

  • Anonymous
    December 30, 2010
    To get around the "wordwrap" just change the size of your cmd prompt window defaults to 132 characters.

  • Anonymous
    April 21, 2011
    nice one, thanx! and Martin, also thanx for the wordwrap tip

  • Anonymous
    February 15, 2013
    This is awesome! Thanks for sharing!

  • Anonymous
    October 06, 2013
    Awesome!  Why oh why isn't this built in to Visual Studio?

  • Anonymous
    October 07, 2014
    Do it right or do not it! the argument is WRONG