LogoASPAlliance: Articles, reviews, and samples for .NET Developers
Where's My Assembly!?
by J. Ambrose Little
Average Rating: 
Views (Total / Last 10 Days): 26745/ 71


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.

Product Spotlight
Product Spotlight 

©Copyright 1998-2023  |  Page Processed at 2023-09-29 8:13:35 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search