Web Design that taps into the haromny and vision of your dreams.

Global Assembly Cache (GAC)

Guide to the Global Assembly Cache

Written By on in C#

433 words, estimated reading time 2 minutes.

The Global Assembly Cache (GAC) is a machine-wide cache of strongly named .Net assemblies and acts as a central repository for shared libraries.

Introduction to the .Net Framework Series
  1. What is Microsoft .Net?
  2. Benefits of using the .Net Framework
  3. Languages in the .Net Framework
  4. The C# vs Visual Basic Question
  5. Common Language Runtime
  6. The .Net Common Language Specifications
  7. Global Assembly Cache (GAC)

The Global Assembly Cache (GAC) is installed on every machine with the .Net framework and contains a reference to all the strongly named assemblies that have been installed on the machine. The GAC stores assemblies intended to be shared by several applications on the computer and as such you should only install libraries into the GAC when you need to. As a general guideline, keep assembly dependencies private, and locate assemblies in the application directory unless sharing an assembly is explicitly required.

Assemblies installed into the GAC must be strongly named. When an assembly is added to the global assembly cache, integrity checks are performed on all files that make up the assembly. These checks ensure that an assembly has not been tampered with, but do not ensure that the publisher is who they say they are.

Why Use the Global Assembly Cache?

There are several advantages to using the GAC for shared assemblies. These include:

  • Shared Location: Assemblies that are used my many applications can reference the GAC, instead of a separate version being distributed with each application.
  • File Security: Administrators often protect the WINNT directory using an Access Control List (ACL) to control write and execute access. Because the global assembly cache is installed in the WINNT directory, it inherits that directory's ACL. It is recommended that only users with Administrator privileges be allowed to delete files from the global assembly cache.
  • Versioning: Because the assemblies are strongly named, they have a unique reference which allows multiple versions to be installed on the same machine. This allows for older applications to reference the old assembly, while newer applications to use a later version.

Installing to the GAC

There are two methods for installing an assembly into the global assembly cache; using the Windows Installer deployment tool, or manually using the gacutil.exe tool. Gacutil.exe should not be used to unless the assembly is to be installed on a development machine. The recommended method is to use the Windows Installer as it provides reference counting of assemblies in the global assembly cache, plus other benefits.

Using Windows Installer

To install an assembly using the Windows Installer, create a new installer project and click on the menu View ยป File System. On the left hand side, right click and select "add global assembly cache folder", click on the GAC then in the right hand side click add. Browse to the assembly to be installed and compile the project.

To use gacutil

To install an assembly into the GAC use the following command:

gacutil.exe -I <assembly name>

To remove an assembly use:

gacutil.exe -U <assembly name>

Last updated on: Friday 23rd June 2017



There are no comments for this post. Be the first!


Leave a Reply

Your email address will not be published.

If you find something abusive or that does not comply with our terms or guidelines please flag it as inappropriate.

Copyright © 2001-2018 Tim Trott, all rights reserved. Web Design by Azulia Designs

This web page is licensed for your personal, private, non-commercial use only.

Disclaimer, Privacy & LegalSitemapContact Me