BlackWaspTM

This web site uses cookies. By using the site you accept the cookie policy.This message is for compliance with the UK ICO law.

Visual Studio
VS 2003+

Show Assemblies in the Add Reference Dialog Box

Visual Studio's Add Reference dialog box allows assemblies to reference each other in order that code from one assembly can be accessed from another. The use of the dialog box can be improved by including custom assemblies in the standard list.

Add Reference Dialog Box

When you are developing software using the .NET framework, you can organise your code into assemblies. This is particularly useful when you are building code libraries. In this situation you can group related code into a single library assembly that is compiled into a dynamic linked library (DLL). This DLL can be referenced by any number of projects that need to use the library code.

When you want to use an external assembly from your project, you can add a reference to it using the Add Reference dialog box. This shows several lists of available assemblies in a tabbed arrangement. The .NET tab shows common assemblies including the standard .NET assemblies. The COM tab lists available COM components and the Projects tab shows the other projects within the solution. Depending upon the version of Visual Studio being used, you may also see a Recent tab, which shows the most recently referenced assemblies. Additionally, you have the option to browse the file system to find the DLL that you wish to use.

If you have built a code library containing a large number of DLLs, it can be frustrating to have to browse to the library folder and add references one by one. In versions of Visual Studio that include the recent items list, you may find that not all library DLLs are shown as the list size is limited. You can alleviate these problems by adding your own assemblies to the ".NET" list.

Adding Library Folders to the Add Reference Dialog Box

When you wish to add your own assemblies to the .NET tab of the dialog box, it is easiest to copy the DLLs into a single folder. You can segregate the DLLs into several folders but as they must be added one folder at a time, keeping them together makes the process easier. In the images in this article I have copied a DLL into the c:\Assemblies folder. To tell Visual Studio where the assemblies reside, you must edit the registry. To do so, run the program "regedit.exe".

NB: If you make a mistake whilst editing the registry you may leave the operating system unusable. If you are not comfortable editing the registry, you should not do so.

Adding Assemblies in Visual Studio 2003, 2005 or 2008 (32-bit)

The process for registering a folder containing assemblies varies according to the version of Visual Studio that you are using and whether you have a 32-bit or 64-bit operating system. I'll describe the process for Visual Studio 2008 or earlier in a 32-bit environment first. Later we'll see the differences for other environments.

When you register a new assembly folder, you can elect to include it only for the current user or for every user of the machine. If you only want to show your own assemblies for yourself, make the registry modifications within the HK_CURRENT_USER branch of the registry tree. To modify the list for every user, you should make the changes to the HK_LOCAL_MACHINE branch.

Within the chosen branch, expand the Software key and then the Microsoft key. If this contains a key named, ".NETFramework", expand this also. If not, create it. Within the .NETFramework key, expand or create the AssemblyFolders key.

The assembly folder definitions are created as keys within the AssemblyFolders branch. First create a key with a name that is appropriate. Once created, double-click the "(Default)" value within the new key and enter the full path to the folder. The end result will be similar to that shown below. Here I have created a key named "BlackWasp" with the path, "c:\Assemblies".

AssemblyFolders key in Registry

Once the key and its values are added to the registry, restart Visual Studio. After restarting and creating or opening a solution, right-click the project in the Solution Explorer and choose Add Reference to show the dialog box. The assemblies within the named folder will be included in the dialog box, as shown below:

Custom assembly in Add Reference dialog box

Adding Assemblies in Visual Studio 2003, 2005 or 2008 (64-bit)

If you are using a 64-bit version of Windows, you must use a different registry path when adding the new folder key. The only difference is that you must include the Wow6432Node key within the SOFTWARE section. For example, in a 32-bit environment the key for the folder might have the path below. NB: The ".." should be replaced with either HK_CURRENT_USER or HK_LOCAL_MACHINE.

..\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MyAssembliesFolder

When using a 64-bit operating system this should be changed to the following:

..\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\AssemblyFolders\MyAssembliesFolder

Adding Assemblies in Visual Studio 2010

When using Visual Studio 2010, the paths are modified further. Firstly, the AssemblyFolders key becomes AssemblyFoldersEx. Additionally, beneath the .NETFramework item you must add an extra key that specifies the lowest version number of .NET that the assemblies in the folder are targeted at. The following registry path is for assemblies that can be used with .NET framework version 4.0.30319 or later:

..\SOFTWARE\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx\MyAssembliesFolder

Again, if you are using a 64-bit environment you must include the Wow6432Node key:

..\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319\AssemblyFoldersEx
\MyAssembliesFolder
17 July 2011