in

Platinum Bay

Peace, Love, Team System, and Community

This Blog

Syndication


.NETicated

Add Reference and the GAC

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.

Published Sep 02 2008, 09:18 AM by Steve
Filed under:

Comments

September 2, 2008 7:20 AM

If you want to add a reference to an assembly in the GAC, you don't have to go through all that. SharpDev will allow you to add a reference to the assembly from Add Reference.

sharpdevelop.net/.../Default.aspx

 

September 3, 2008 6:07 AM

Pingback from  Dew Drop - September 3, 2008 | Alvin Ashcraft's Morning Dew

 

September 7, 2008 8:04 AM

My latest in a series of the weekly, or more often, summary of interesting links I come across related to Visual Studio. Sara Ford's Tip of the Day #305 shows how to reevaluate expressions in the QuickWatch window . Brad Abrams explains how VS208 Multitargeting

 

September 14, 2008 9:39 PM

Unable to add reference to assemblies in GAC from VS

 

December 13, 2008 9:06 AM

on 64 bit systems, you need to add your assembly folder to [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\AssemblyFolders] (HKEY_CURRENT_USER resp.) instead to make this work.

 

December 13, 2008 1:07 PM

@Ryan - Thanks!

@Erich - Noted, thanks!

 

June 4, 2009 11:31 AM

Thanks dude...

Chris
 

June 18, 2009 10:50 AM

Was searching on this topic and saw your blog in the search results, so I knew it had to be a quality answer.  Nice work! Thanks Steve.

 

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews is a Team System MVP and INETA Speaker, and has been working as a developer for more than 9 years. During this time, he has designed and developed applications in such widely varying areas as trust accounting, medical information management, supply chain management, and retail systems. Steve is also an MCP, ICSOO, Speaker Liaison for the Philly .NET User Group, and community fanatic.
Powered by Community Server (Commercial Edition), by Telligent Systems
© Platinum Bay | Some Rights Reserved Creative Commons License

Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or annonymous comments) - so keep it polite, please.