Adding assemblies to the Add References dialog in Visual Studio 2005
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:
- 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.
- 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.
- 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>