One common misconception regarding Visual Studio that I run across quite frequently involves the Add Reference dialog and the GAC.
Adding a reference to a Visual Studio project is as simple as right-clicking on the References folder, choosing "Add Reference…", and selecting the reference you wish to add from the dialog box that appears. However, and here is the confusion, assemblies that have been registered in the GAC will not appear in this list. This is because the Add Reference dialog does not enumerate the assemblies installed in the GAC. Rather, it is path-based and uses several registry keys to locate assemblies with which to populate the dialog.
Registry Keys:
The registry keys used by Visual Studio to populate the Add References dialog are:
- [HKEY_LOCAL_MACHINE]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
- [HKEY_CURRENT_USER]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
To add your assembly folder, create a sub key with a descriptive name, and set the default REG_SZ value to the folder path. If Visual Studio is open, it must be restarted for the added folder path to be enumerated. Notice that both the Local Machine and Current User registry hives are listed above. You can add assembly folders to either key to scope them if needed.
Example:
[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders\MyAssemblies]@="C:\\MyAssemblies"
As a closing note, remember that it is not recommended to install assemblies to the GAC unless they need to be shared among multiple applications running on the system.