Where's My Assembly!?
 
Published: 08 Oct 2003
Unedited - Community Contributed
Abstract
How to make your life easier and impress your friends by easily adding assemblies to the .NET Add Reference dialog assembly listing.
by J. Ambrose Little
Feedback
Average Rating: 
Views (Total / Last 10 Days): 26419/ 60

Introduction

Originally Published: 17 February 2003

This article is for two groups of people: Those who don't know how to make assemblies show up in the .NET Add Reference dialog or those who do but never thought about making their lives easier by taking advantage of that feature. Keep reading if you fit one of these descriptions (or even if you're just bored!). There are just a few simple things you can do to make your life easier and impress your friends.

 

In Depth

First, I recommend you create a shared directory that's easy to remember where you will store all of the assemblies that you want to show up in the dialog. For this I chose C:\Program Files\Microsoft.NET\Third-Party Tools . Although we could argue about the semantics, I think this basically covers anything not included with the .NET Framework, and it is easy to remember and not user-specific.

Next, you'll want to open up that friendly program, RegEdit, and go to \\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders and add a new key, calling it whatever you want. It really doesn't matter what you call this except for when you look it up in the registry. For consistency's sake though, I named it 'Third-Party Tools'.  Then you simply need to change the (Default) string value to be the path to the directory you created for this purpose, which is, in my case, C:\Program Files\Microsoft.NET\Third-Party Tools.  See the screen shot below for the complete picture.

That's it!  Well, that's all the one-time setup required to have items in the aforesaid folder appear in the .NET Add Reference dialog.  But of course, you'll need to add assemblies to that folder for it to be of any use whatsoever.  Below is a screen shot of my current .NET Add Reference dialog.  You can see an assembly in it that is in this folder on my hard drive, specifically the ASPAlliance.Common assembly.  There are others in my dialog that are farther down the list as well. 

Now, to add or remove entries from this dialog, all I have to do is add or remove assemblies from the Third-Party Tools folder I created.  It's that simple--no more browsing all over the disk to find this or that assembly.  All I have to do is drag and drop an assembly into that folder and voila!, it appears for easy selection in this list.  Naturally, you can extend this concept and create as many entries into the AssemblyFolders key to accommodate as many of these drag-and-drop locations as you want, but if you do that, you'll reduce the ease of use factor added by using just one location.  On the other hand, if you have multiple, side-by-side versions of the same assembly, you may have to create special entries for it.

Important Notes

Often developers think that if they create a strongly-named assembly and drop it into the Global Assembly Cache (GAC) that it should show up in the .NET Add Reference dialog list automatically.  Let me tell you that this is simply not the case.  Even Microsoft did not pull off this magic.  This is due to the directory structure of the GAC that puts each assembly into its own unique directory using parts of the strong name.  That is how they enable side-by-side versioning in the GAC (but this may change in future versions). 

In any event, the point here is that you will have to have two copies of your shared assemblies (i.e., assemblies in the GAC) on your development box, one in the GAC and one in a separate location for referencing at compile time.  Microsoft does this and so should you if you want to make your life easier. See C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705 for their compile-time assemblies (notice the XML documentation files included there as well to enhance Intellisense). These are the ones you see in the .NET Add Reference dialog, but the copies the applications that you build use at runtime are actually located elsewhere in the GAC directory structure.

I say all that to point out that the steps you took above will make displaying your shared assemblies in the .NET Add Reference dialog quite simple--just drop them (and their XML documentation files if available) into the Third-Party Tools folder after you put them in the GAC and they will neatly appear in the dialog.  That's just one extra, easy step to make your life easier.  And if you're distributing shared assemblies, you should make your customers' lives easier by automatically putting your assembly into a folder that is under the AssemblyFolders key during your assembly's installation (as you can see aspNetEmail has done in my screen shots).

One last note is that you may need to restart VS.NET after adding new assemblies to the Third-Party Tools location before they will show up in the .NET Add Reference dialog listing.

 

Boiled Down

  1. Create an easy-to-remember folder on your hard drive.
  2. Add a key under \\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders with a default value of the path to the directory created in Step 1.
  3. Copy an assembly (and its XML documentation file if available) to the directory created in Step 1.
  4. Restart VS.NET if necessary.


User Comments

Title: thumbs up   
Name: Fadi
Date: 2008-05-06 5:38:32 AM
Comment:
thx
Title: Software Engineer   
Name: D. P.
Date: 2007-04-12 1:46:17 PM
Comment:
thank you very much. I have been scouring the net trying to figure this one out!
Title: developer   
Name: nobuakiy
Date: 2006-02-12 4:48:47 AM
Comment:
Yes, It's magic.
My life got easier.
Title: Software Engineer   
Name: D.Ramana
Date: 2006-01-03 2:23:33 AM
Comment:
This is very nice article. Once read this article every one get the idea..
Title: Great Article   
Name: Daniel
Date: 2005-08-22 5:03:58 AM
Comment:
Thanks for the article.
Title: developer   
Name: yogi
Date: 2005-05-05 7:13:14 AM
Comment:
magic,
Before reading this article, I was wasting time manually copying dll's between apps and generally tying myself in knots.

liberation...
cheers,
yogi
Title: IT Consultant   
Name: Prasad Thiriveedi
Date: 2005-01-25 6:30:09 PM
Comment:
Excellent article. Neat idea.
Title: R.N.   
Name: Merrie
Date: 2004-09-17 9:55:38 AM
Comment:
Thank you so much for writing such an informative article! I have been trying to figure out some of this stuff for a couple of years - no I am not a computer pro - just a home user. Have a great day!
Title: Technical Systems Analyst   
Name: Claudio Sanchez
Date: 2004-08-19 2:54:49 PM
Comment:
Excellent article. I'm working on several projects that share some assemblies and have to go to different directories to add them or refresh them. This is a neat idea will save me a lot of work,
Thanks.
Claudio

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2022 ASPAlliance.com  |  Page Processed at 2022-09-24 4:07:22 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search