Mel Lota's Weblog

Silverlight, SharePoint and other related technologies

WebPart Tip: How to quickly view the public key for an assembly in the output window

 

I saw this handy little helper function being used on a MOSS screencast by Todd Bleeker and decided to figure out how he did it :). Basically it allows you to view the public key token of an assembly from within Visual Studio's output window, which saves time when you need to grab the key for use with the safe control entries in the web.config for example.

First step, fire up your copy of Visual Studio 2005 and open up a webpart class library project. Then from the Tools menu select External Tools. This will bring up the following dialog:

 

From the options, click Add and then give your utility a title. Now all we're doing here is essentially grabbing the output from the sn.exe command, so you will need to provide the path to your local sn.exe file. Mine was located in the following folder:

C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\sn.exe 

Now, just like if we were running the strong name utility from the command line, we're going to need to pass in the correct arguments. Firstly we'll need to pass the -Tp argument, as we want to get the token for the public key, together with the public key itself. Then we need to specify the target assembly, which can be done by clicking on the button to the right of the Arguments field and selecting 'Target Path'. This basically gets the full qualified path to item which is being built, in our case a webpart assembly. Lastly just tick the 'Use Output Window' checkbox and then click ok and you're good to go :)

The new utility you've just created should now show up in the Tools menu, you can go ahead and click it and you should now see the output window popup with the details of the public key. This is a really nice feature of Visual Studio and I'm sure this can be tailored for many other uses.

Comments

Christopher Bermingham said:

Very cool tip, thanks!

I had previously been using the Microsoft.NET Framework 1.1 Configuration Tool, which took forever.

# October 25, 2007 9:58 AM

.Net Adventures said:

How to quickly view the public key for an assembly in the output window Speed up Visual Studio 2005 Create

# October 25, 2007 6:11 PM

Links (10/25/2007) « Steve Pietrek’s SharePoint Stuff said:

Pingback from  Links (10/25/2007) « Steve Pietrek’s SharePoint Stuff

# October 25, 2007 8:42 PM

Christopher Steen said:

Link Listing - October 27, 2007

# October 27, 2007 10:56 AM

Interesting articles (October 26) | devintelligence.com said:

Pingback from  Interesting articles (October 26) | devintelligence.com

# July 27, 2008 7:12 AM

Rem said:

The blog is helpfull...

visit also <a href="http://asp-net-example.blogspot.com"><b>asp.net example</b></a>

# November 3, 2008 10:01 AM

osbornm said:

Very Clever

# December 11, 2008 1:51 AM

nick_eldarr said:

# December 27, 2008 11:25 AM

Vandana said:

Great tips. And also I suggest please check the release of service pack 2 for WSS 3.0 and Moss 2007.

Microsoft has fixed lot of issues in the SP2. You can check some of the major issues that has been fixed in the SP2 here www.ekhichdi.com/.../issues-fixed-by-service-pack-2-(sp2)-in-the-2007-office-server-products

Also I heard that they are going to release the April CU but it will not have SP2 in it.

# May 7, 2009 2:59 PM

nick_lirobo said:

# May 16, 2009 7:44 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)