5

I have an Interop assembly lying in GAC; Windows Explorer clearly shows it listed in the C:\WINDOWS\assembly folder. Yet, when I try to add a reference to it in from Visual Studio, I can't see it anywhere in the Add Reference dialog.

If this is happened to you too, what is the reason for this? And how do I fix this?

(The assembly is actually located in C:\WINDOWS\assembly\GAC_MSIL folder, if you must know.)

G S
  • 35,511
  • 22
  • 84
  • 118

7 Answers7

5

Add one of the following registry keys, where is the directory to search, and MyAssemblies is the category of your assemblies. Note HKCU is for the current user and HKLM is for everyone on the same computer.

[HKEY_CURRENT_USER\SOFTWARE\Microsoft\.NETFramework\<version>\AssemblyFoldersEx\MyAssemblies]@="<AssemblyLocation>"

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\<version>\AssemblyFoldersEx\MyAssemblies]@="<AssemblyLocation>"
Sheng Jiang 蒋晟
  • 15,125
  • 2
  • 28
  • 46
  • How does this differ from [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders] (Difference is \AssemblyFoldersEx\MyAssemblies...)? Reading http://support.microsoft.com/kb/306149 I would assume that key without would be the correct one... – RonnBlack Aug 01 '12 at 18:34
  • As noted by @Soundararajan elsewhere on this page, VS will successfully find and build with GAC assemblies if you add them to your `.csproj` file manually. Changing the registry key as described here is only necessary if you want to be able to use the VS `Add Reference` GUI interface. – Glenn Slayden Dec 09 '16 at 04:04
3

I've created a tool 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.

Mosty Mostacho
  • 42,742
  • 16
  • 96
  • 123
BALKANGraph
  • 2,031
  • 1
  • 15
  • 16
2

As other's have pointed out, simply installing an assembly in GAC doesn't ensure it'll show up in the Add Reference Dialog Box. I've found this MSDN page that has the details. See the section To display an assembly in the Add Reference dialog box.

G S
  • 35,511
  • 22
  • 84
  • 118
1

Alternatively, I edited the Project file and added the reference manually.

  1. Install the assembly in GAC. gacutil /i "Foo.dll"
  2. Find the strong name of the assembly. gacutil /l will give you the list from which you can pick.
  3. In the consuming project file add the following line (from the previous step)
  4. <Reference Include="Foo, Version=x.x, Culture=neutral, PublicKeyToken=xxx, processorArchitecture=MSIL" />
  5. And it works. :)
LPL
  • 16,827
  • 6
  • 51
  • 95
Soundararajan
  • 2,000
  • 21
  • 23
0

"C:\WINDOWS\assembly" is a special folder which in Windows Explorer will list the assemblies (and the assembly info) within the various sub-folders.

For your case, you might need to point it to the physical path which is "C:\Windows\assembly\GAC_MSIL.....dll" within VS.NET.

o.k.w
  • 25,490
  • 6
  • 66
  • 63
  • I know that. But how do you 'browse' to that subfolder. Windows explorer won't let you. Are you implying I have to fall back to command-line compilation? There's gotta be a better way. – G S Dec 19 '09 at 14:16
  • Frankly, I'm very puzzled as well. In the first place, if it appears in the assembly folder, you should be able to view in "Browse" tab of the "Add Reference dialog. Sorry pal, hope someone else can help here. – o.k.w Dec 19 '09 at 14:51
0

You can also map the GAC folder to a virtual drive, and then you can add GAC reference through browse tab.

Manual by MZ-Tools

HuBeZa
  • 4,715
  • 3
  • 36
  • 58
-1

Use this command under Visual studio command prompt

regsvr32 /u shfusion.dll

ss.
  • 1