views:

333

answers:

3

I created a homemade assembly and I think I installed it correctly in the GAC using the .Net 2.0 configuration tool (mscorcfg.msu) However, when I want to reference it in visual studio, where do I find it?

( I know, I should not use the GAC anyway, but indulge me ;-))

EDIT: I did not ask the question clear enough: After installing the assembly to the GAC, it does not show up on the .NET tab of the Project-Add Reference menu.

+3  A: 

The add reference dialog actually looks at the registry, in particular:

  • [HKEY_LOCAL_MACHINE]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders
  • [HKEY_CURRENT_USER]\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders

To add your assembly, you must edit these registry keys. Or simply using the "Browse..." button (instead) may be more tempting.

Marc Gravell
Reading your answer reminded me of this very step I had to complete when I still GAC'd assemblies...I went ahead and deleted my answer.
sixlettervariables
... or the version-specific registry keys e.g. SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx
Joe
I found this:-The HKLM key pointed in my case to C:\program files\reference assemblies\microsoft\framework\v3.5-I copied the .dll to that folder and it now showed up on the .Net tab of the Project-Add Reference menuin visual studio-However, I was still greeted wit an assembly not found error while building my main application.-This was solved by installing the .dll to the gac, pointing the installation utility to the location on the C:\ drive specified by the register value.Thanks!
Dabblernl
+1  A: 

When you need to reference an assembly that has been deployed to the GAC, you will need to browse to the \bin\Debug directory of the original project via the Browse tab of the Add Reference dialog in Visual Studio.

The reason this works is that since you've installed the assembly into the GAC, it will have a strong name and therefore a .publickey value in the manifest.

When you reference an assembly whose manifest contains a .publickey value, Visual Studio assumes the strongly named assembly will most likely be deployed to the GAC, and therefore does not bother to copy the binary to your application folder.

Instead, it will use the version in the GAC.

Joe
thanks, a useful extra comment.Actually a thing to be avoided when you deploy your application.
Dabblernl
A: 

Hi Dabblern,

I've created a tool which is completely free, that will help you to achieve your goal. Muse VSReferences will allow you to add a Global Assembly Cache reference to the project from Add GAC Reference menu item.

Hope this hekps,

Muse VSExtensions

Muse VSExtensions