ArticleslgStudy

engineering

Global Assembly Cache

Global Assembly Cache is a engineering topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Global Assembly Cache rather than just read about it. In short: The Global Assembly Cache (GAC) is a machine-wide CLI assembly cache for the Common Language Infrastructure (CLI) in Microsoft's .NET Framework. The approach of having a specially controlled central repository addresses the flaws in the shared library concept and helps to avoid pitfalls of other solutions that led to drawbacks like DLL hell.

Key takeaways

  • Global Assembly Cache belongs to engineering; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Global Assembly Cache to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Global Assembly Cache from memory before moving on to harder problems.

Reference excerpt

The Global Assembly Cache (GAC) is a machine-wide CLI assembly cache for the Common Language Infrastructure (CLI) in Microsoft's .NET Framework. The approach of having a specially controlled central repository addresses the flaws in the shared library concept and helps to avoid pitfalls of other solutions that led to drawbacks like DLL hell.

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 strongly named.

Usage There are two ways to interact with the GAC: the Global Assembly Cache Tool (gacutil.exe) and the Assembly Cache Viewer (shfusion.dll).

Global Assembly Cache Tool gacutil.exe is an older command-line utility that shipped with .NET 1.1 and is still available with the .NET SDK. One can check the availability of a shared assembly in GAC by using the command:

gacutil.exe /l <assemblyName> One can register a shared assembly in the GAC by using the command:

gacutil.exe /i <assemblyName> Or by copying an assembly file into the following location:

%windir%\assembly\ Note that for .NET 4.0 the GAC location is now:

%windir%\Microsoft.NET\assembly\ Other options for this utility will be briefly described if you use the /? flag, i.e.:

gacutil.exe /?

Assembly Cache Viewer The newer interface, the Assembly Cache Viewer, is integrated into Windows Explorer. Browsing %windir%\assembly\ (for example, C:\WINDOWS\assembly) or %WINDIR%\Microsoft.NET\assembly, displays the assemblies contained in the cache along with their versions, culture, public key token, and processor architecture. Assemblies are installed by dragging and dropping and uninstalled by selecting and pressing the delete key or using the context menu. With the launch of the .NET Framework 4, the Assembly Cache Viewer shell extension is obsolete.

Example of use A computer has two CLI 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 CLI. The folders within "systemroot" named assembly and Microsoft.NET\assembly (for .NET 4.0) contain 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. Windows 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 a version of an assembly when referencing it, so the run-time 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, such as:

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. Every assembly that is added to the GAC must be strongly named. The process of making an assembly "strongly named" can be quite painful in some situations. For example, if an assembly depends on another assembly that is not strongly named, it cannot be registered in the GAC. In cases where the code of the third-party assembly is not in the programmer's possession, transforming the assembly to be strongly named can in fact be impossible. Browsing for files using standard Windows APIs doesn't allow selection of DLLs located under the "assembly" folder when Explorer is showing the user-friendly view of the GAC.

See also Download Cache .NET Framework

References

External links .NET Framework Developer's Guide Archived 2008-10-06 at the Wayback Machine Global Assembly Cache Tool (gacutil.exe) Archived 2008-10-15 at the Wayback Machine Demystifying the .NET Global Assembly Cache Archived 2017-09-22 at the Wayback Machine

Worked examples

Example 1 — a first encounter with Global Assembly Cache

Start with the simplest possible case. Write down what Global Assembly Cache claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In engineering, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Global Assembly Cache before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Global Assembly Cache ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Global Assembly Cache

In research
Global Assembly Cache appears in engineering research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Global Assembly Cache in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Global Assembly Cache is common in secondary-school and first-year university syllabi. It links to neighbouring topics .NET terminology, Common Language Infrastructure, Windows administration, so understanding it makes those chapters shorter.
In everyday life
Look for Global Assembly Cache outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Global Assembly Cache” →

How to study Global Assembly Cache in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Global Assembly Cache means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Global Assembly Cache out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Global Assembly Cache in simple terms?

The Global Assembly Cache (GAC) is a machine-wide CLI assembly cache for the Common Language Infrastructure (CLI) in Microsoft's .NET Framework. The approach of having a specially controlled central repository addresses the flaws in the shared library concept and helps to avoid pitfalls of other so…

Why does Global Assembly Cache matter?

Because it connects several engineering ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Global Assembly Cache?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Global Assembly Cache.

Tags

  • .NET terminology
  • Common Language Infrastructure
  • Windows administration

Keep exploring