Aaron Stebner's WebLog

Thoughts about setup and deployment issues, WiX, XNA, the .NET Framework and Visual Studio

Adding assemblies to the Add References dialog in Visual Studio 2005

Adding assemblies to the Add References dialog in Visual Studio 2005

Rate This
  • Comments 6

I heard from a customer and a Microsoft employee asking how to register new assemblies so that they will be listed in the Add References dialog in Visual Studio 2005.  I have always done this in the past by using the Browse button and finding a copy of the assembly on my local drive, so I did a bit of research to try to figure out how to pre-populate assemblies in the list for the Add References dialog.

Unfortunately, installing the assembly to the GAC does not automatically populate it into the Add References dialog, even in Visual Studio 2005 (and this despite the fact that this MSDN document claims that assemblies in the GAC will be listed in VS 2005).

Here are some options I found that worked for me when I tried them on my machine:

  1. Add a new sub-key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx (or the same sub-key under HKEY_CURRENT_USER if you want the assemblies to appear only for the current user instead of all users).  The default value of the sub-key should be the folder path that you want Visual Studio to look in for assemblies to include in the Add References dialog.  This registry path is specific to VS 2005 and the .NET Framework 2.0 and will not work for previous versions of VS or the .NET Framework.  It is documented in this MSDN document.
  2. Add a new sub-key under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders (or the same sub-key under HKEY_CURRENT_USER if you want the assemblies to appear only for the current user instead of all users).  The default value of the sub-key should be the folder path that you want Visual Studio to look in for assemblies to include in the Add References dialog.  This registry path is global and any folders listed here will be processed by VS .NET 2002, VS .NET 2003 and VS 2005 as well as the .NET Framework 1.0, 1.1 and 2.0.  It is documented in this KB article.
  3. Place a copy of the file in the folder c:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PublicAssemblies.  This path is dependent on the version of Visual Studio that you have installed and whether or not you installed it to the default path, so you may need to adjust it as needed for your system.  The path that I list is for a default install of VS 2005.

I am not an expert in populating the Add References dialog, and this list is mostly intended to be a list of options that I discovered that worked correctly when I tried them out in my limited scenarios.  If you need to add assemblies to the Add References dialog, it appears based on my research that the options I listed above are in the order of preference.

In other words, you should use the AssemblyFoldersEx registry value if it is feasible for your scenario.  If that is not possible because you are running VS 2002 or 2003 or want to add your assembly to the Add References dialog in all versions of Visual Studio instead of just a specific version, then you should use the AssemblyFolders registry value.  If there is some reason you cannot use either of those registry values, copying your files to the PublicAssemblies folder will also work, though that is not the recommended approach.

<update date="11/29/2005"> Adding more detailed information about recommendations for which option to choose </update>

 

  • I would've noted that option 3 is NOT a preferred way of dealing with common assembly registration for obvious reasons (figuring out VS version during installation, etc)
  • Hi Eric - I agree with your statement. I was trying to list a variety of options I found while researching this issue, but I should make it more clear that I have listed them in what appears to be the order of preference based on the documentation I have read and the folks that I talked to on the Visual Studio team. I will update the main blog post to better reflect this.

  • If I have two versions of an assembly, one for regular .Net, the other for the Compact Framework, how can I make each one appear in the respective Add References dialog?
  • PingBack from http://www.hilpers.it/2653647-registrare-componenti-nella-gac

Page 1 of 1 (6 items)
Leave a Comment
  • Please add 8 and 2 and type the answer here:
  • Post