Ver versión en español    
 
Home
10 Reasons to use MZ-Tools
MZ-Tools 6.0 for VS.NET
Editions
Features
Online Documentation
MZ-Tools SDK
Download
Purchase
Version History (RSS)  
FAQ & Support
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
Version History (RSS)  
FAQ & Support
User Reviews
Community Place
Contact  
For Add-In Developers
About
   
User Testimonials

I'm an avid supporter of MZ-Tools. It's a product I couldn't do without and your level of support is outstanding.

Jan Hyde (Visual Basic MVP)

You will soon wonder how you ever lived without it.

Andy Maggs

More user reviews
 
HOWTO: Reference a Visual Studio assembly in the GAC from an add-in

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: February 2007   Microsoft Visual Studio .NET 2003
      Microsoft Visual Studio 2005

Introduction

Visual Studio uses assemblies that, among others, are in one of these subfolders of C:\Program Files\<Microsoft Visual Studio folder>:

  • \Common7\IDE
  • \Common7\IDE\PublicAssemblies
  • \Common7\IDE\PrivateAssemblies

But some assemblies are installed only in the Global Assembly Cache (GAC). The GAC is a special folder typically located at C:\Windows\Assembly which stores different versions of shared assemblies used at run-time by .NET applications. The GAC is actually a set of folders, but when you use the Windows Explorer to browse that folder, a shell extension shows a unified view (assembly name, version, culture, public key token and arquitecture) of all installed assemblies.

Sometimes your add-in project needs to reference an assembly that is only in the GAC or installing the VSIP / Visual Studio 2005 SDK, for example, the Microsoft.VisualStudio.OLE.Interop.dll assembly.

More Information

If you don't want to install the Visual Studio SDK stuff on your computer just to reference an assembly that is only in the GAC, since Visual Studio doesn't allow to add references to an assembly in the GAC (because the GAC is a deployment feature, not a development feature) you can follow this procedure to extract the assembly from the GAC:

  • Open a MS-DOS command window (click Start, Run... type cmd and press enter)
  • Use the SUBST command to map a drive letter to the GAC folder:

SUBST G: C:\Windows\Assembly

That maps the drive letter G: to the GAC folder. With the SUBST command you bypass the shell extension.

  • Use Windows Explorer to browse the G: folder. You will see the actual folders, with names like GAC, GAC_32, GAC_MSIL and one subfolder for each assembly. Once you locate the assembly DLL that you are looking for, you can copy it outside the GAC, to the \bin folder of your add-in project and add a reference to it. For example, the Microsoft.VisualStudio.OLE.Interop.dll is in the folder G:\GAC\Microsoft.VisualStudio.OLE.Interop\7.1.40304.0__b03f5f7f11d50a3a.
  • When done, you can undo the mapping the using:

    SUBST G: /D

Most Visual Studio assemblies are not redistributable, which means that your setup should not include them. Rather, Visual Studio (which installs those assemblies in the GAC) should be a prerequisite on the target computer.


Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this


   Top