Global Assembly Cache

Global Assembly Cache

The Global Assembly Cache or GAC is a machine-wide .NET assemblies cache for Microsoft's CLR platform. The approach of having a specially controlled central repository addresses the shared library concept and helps to avoid pitfalls of other solutions that lead to drawbacks like DLL hell.

Purposes

There are several reasons to install an assembly into the GAC:

hared location

Assemblies that should be used by all applications can be put in the global assembly cache. For example, if all applications should use an assembly located in the global assembly cache, a version policy statement can be added to the Machine.config file that redirects references to the assembly.

Requirements

Assemblies residing in the GAC must adhere to a specific versioning scheme which allows for side-by-side execution of different code versions. Specifically, such assemblies must be strong named.

Usage

gacutil.exe is the .NET utility used to work with the GAC.

One can check the availability of a shared assembly in GAC by using the command:

gacutil.exe /l

One can register a shared assembly in the GAC by using the command:

gacutil.exe /i

Other options for this utility will be briefly described if you use the /? flag, i.e.:

gacutil.exe /?

Example of use

A computer has two .NET assemblies both named AssemblyA, but one is version 1.0 and the other is version 2.0. Since it is required that both be compiled to a file named AssemblyA, they cannot exist in the same directory within the FAT32 file system. Instead, the virtual file system of the GAC can be used by programs that need to use each version of the assembly specifically.

Implementation

The GAC as a construct does not actually exist within the Windows OS. It is implemented and managed by the .NET Framework. The folder within %systemroot% named assembly contains all globally-available assemblies with managed filenames so that the version and public key tokens can be included. Each version can therefore exist within the same location and be called without requiring subsequent versions to preserve code entry point locations as usual. Explorer allows the drag-and-drop installation of assemblies into this folder only if they would otherwise be permitted to be installed from the command line.

A calling application may specify specific versions of an assembly when referencing them, so the Common Language Runtime can simply refer to the filename to use the correct one.

Pitfalls

The Global Assembly Cache mechanism helps to avoid older DLL hell, but it still has some drawbacks, as for example [cite web
url=http://www.devsource.com/c/a/Techniques/Ten-Managed-Application-Pitfalls-that-Kill-Version-Compatibility/
title=Ten Managed Application Pitfalls that Kill Version Compatibility
first=Mueller|last=John
publisher=devsource.com
date=2005-02-11
accessdate=2008-01-26
] :
* By default, applications will only run with the version of the .NET Framework used to compile it, which can cause the application to fail on machines with newer versions of the .NET Framework installed — even when the application would normally run properly with the newer version.
* It is sometimes necessary to use Conditional compilation if some of the core .NET calls (used in the application) are only supported for some versions of the framework.
* .NET applications that rely on native code risk incompatibilities, even with the GAC mechanism.

ee also

* Download Cache
* .NET

References

External links

* [http://msdn2.microsoft.com/en-us/library/yf1d93sz.aspx .NET Framework Developer's Guide]
* [http://msdn2.microsoft.com/en-us/library/ex0ss12c.aspx Global Assembly Cache Tool (gacutil.exe)]
* [http://www.codeproject.com/dotnet/demystifygac.asp Demystifying the .NET Global Assembly Cache]


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Global Assembly Cache — Chaque ordinateur sous Windows sur lequel le Common Language Runtime est installé possède un cache de code à l échelle de l ordinateur appelé Global Assembly Cache. Le Global Assembly Cache stocke les assembly spécialement destinés à être… …   Wikipédia en Français

  • Global Assembly Cache — Der Global Assembly Cache (GAC) ist ein Verfahren des .NET Frameworks, um Versionskonflikte zwischen Programmbibliotheken zu vermeiden. Inhaltsverzeichnis 1 Identität und Installation im GAC 2 Implementierung des GAC unter Windows 2.1 Dateisystem …   Deutsch Wikipedia

  • Download Cache — Not to be confused with web cache. The Download Cache, or downloaded files cache, is a component of Microsoft s .NET Framework that is similar to the Global Assembly Cache except that it caches assemblies that have been downloaded from the… …   Wikipedia

  • .NET assembly — In the Microsoft .NET framework, an assembly is a partially compiled code library for use in deployment, versioning and security. In the Microsoft Windows implementation of .NET, an assembly is a PE (portable executable) file. There are two types …   Wikipedia

  • .NET-Framework — Basisdaten Entwickler: Microsoft Aktuelle Version …   Deutsch Wikipedia

  • .NET-Klassenbibliothek — NET Framework Basisdaten Entwickler: Microsoft Aktuelle Version …   Deutsch Wikipedia

  • .NET 3.0 — NET Framework Basisdaten Entwickler: Microsoft Aktuelle Version …   Deutsch Wikipedia

  • .NET Framework — Basisdaten Entwickler: Microsoft Aktuelle Version …   Deutsch Wikipedia

  • .NET Framework 3.0 — NET Framework Basisdaten Entwickler: Microsoft Aktuelle Version …   Deutsch Wikipedia

  • .Net — Framework Basisdaten Entwickler: Microsoft Aktuelle Version …   Deutsch Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”