How can I reference a dll in the GAC from Visual Studio?

This assembly is located in the GAC: Microsoft.SqlServer.Management.RegisteredServers.dll

How to add a link to this assembly in Visual Studio?

I can view the file in c: \ windows \ assembly \

+43
visual-studio assemblies gac
Jan 14 '09 at 21:01
source share
10 answers

As others have said, most of the time you will not want to do this because it does not copy the assembly into your project and will not be deployed with your project. However, if you are like me and trying to add the link that all the target machines have in their GAC, but this is not a .NET Framework assembly:

  • Open the Windows Start dialog box (Windows Key + r)
  • Type C: \ Windows \ assembly \ gac_msil. This is some weird hack that allows you to browse your GAC. You can only get to it through the launch dialog. I hope that my dissemination of this information will ultimately not force Microsoft to correct and block it. (Too paranoid ?: P)
  • Find your assembly and copy its path from the address bar.
  • Open the Add Link dialog box in Visual Studio and select the Browse tab.
  • Paste the path to your GAC assembly.

I do not know if there is an easier way, but I did not find it. I also often use step 1-3 to host .pdb files with my GAC assemblies to make sure they are not lost when I need to use Remote Debugger later.

+52
Sep 16 '10 at 15:57
source share

I created a completely free tool that will help you achieve your goal. Muse VSReferences will allow you to add a global assembly caching link to the project from the "Add GAC Link" menu item.

Hope this helps Muse VSExtensions

+14
Apr 29 '10 at 8:07
source share

Registering assmblies in the GAC then does not put the assembly reference in the add links dialog box. You still need to reference the assembly along the path for your project, the main difference is that you do not need to use the local copy option, your application will find it at runtime.

In this particular case, you just need to reference your assembly along the path (view) or if you really want to have it in the add link dialog box, there is a registry setting in which you can add additional paths.

Please note: if you send your application to someone who does not have this assembly, you will need to send it, in which case you really need to use SharedManagementObjects.msi distributed.

+11
Jan 14 '09 at 21:54
source share

In VS2010, from the "Add Registers" window, you can click "Browse" and go to C: \ Windows \ Assembly and add links to the necessary assemblies. Please note that files can be grouped into different folders, such as GAC, GAC_32, GAC_64, GAC_MSIL, etc.

+6
Apr 29 2018-11-11T00:
source share

In VS, right-click your project, select "Add Link ..." and you will see all the namespaces that exist in your GAC. Select Microsoft.SqlServer.Management.RegisteredServers and click OK and you should be good to go

EDIT:

That is how you want to do this most of the time. However, after some conversation, I found this problem in MS Connect. MS says this is a known deployment issue and they have no job. The guy says that if he copies the dll from the GAC folder and throws it into his trash can, it works.

+5
Jan 14 '09 at 21:11
source share

The only way that worked for me was to copy the dll to your desktop or something else, add a link to it, and then remove the DLL from the desktop. Visual Studio updates itself and finally references the dll from the GAC on its own.

+4
Jan 18
source share

Assuming you alredy tried "Add Link ..." as explained above and failed, you can look here . They say that you need to fulfill some prerequisites: -.NET 3.5 SP1 - Windows Installer 4.5

EDIT: according to this post this is a known issue.

And this may be the solution you are looking for :)

+2
Jan 14 '09 at 21:14
source share

It may be too late to answer, but I found a very simple way to do this (without hacking).

  • Put your dll in the GAC (for 3.5 Drag Drop inside "C: \ Windows \ assembly \")
  • GoTo Projects → Properties
  • Click Link Path (for 3.5 "C: \ Windows \ assembly \")
  • and build

Hope this helps

+1
Jun 19 '15 at 2:59
source share

Relevant files and links can be found here:

http://msdn.microsoft.com/en-us/library/cc283981.aspx

Pay attention to links to it about implementation of / etc.

0
Jan 13
source share

I found this extension for VS 2013 Vitevic GAC Reference .

0
Aug 14 '15 at 9:38
source share



All Articles