ALERT

Stop Ransomware Mid-Flight

Global Assembly Cache (GAC)

Definition - What does Global Assembly Cache (GAC) mean?

The Global Assembly Cache (GAC) is a folder in Windows directory to store the .NET assemblies that are specifically designated to be shared by all applications executed on a system.

The concept of GAC is the result of the .NET architecture whose design addresses the issue of "DLL hell" that existed in COM (Component Object Model). Unlike in COM, there is no need for the assembly in GAC to be registered before its use. Each assembly is accessed globally without any conflict by identifying its name, version, architecture, culture and public key.

Techopedia explains Global Assembly Cache (GAC)

The GAC is a machine-wide code cache used for side-by-side execution of assemblies. The GAC implements the feature of shared library where different applications reuse the code placed in the files located in a common folder. In .NET 4.0, its default location is: %windir%\Microsoft.NET\assembly

The GAC is also the first in the search path while loading a .NET assembly. The only requirement for an assembly to be deployed in GAC is that it should have strong name. The CLR (Common Language Runtime) refers an assembly based on specific version mentioned by the calling application. The virtual file system of GAC helps to fetch the version-specific assembly.

The two tools related to GAC are GAC Tool (gacutil.exe) and Assembly Cache Viewer (shfusion.dll). GAC Tool is used to check for assembly existence, register a shared assembly, view and manipulate contents of GAC, etc. Being a system folder, it requires administrator privileges to be used. Assembly Cache Viewer is used to display the details (version, culture, etc.) associated with the assemblies contained in the cache.

GAC provides the benefits of code reuse, file security (due to its installation in ‘systemroot’ directory and hence deletion is only by users with Administrator privileges), side-by-side execution (allowing multiple versions of an assembly maintained in the same folder), etc.

One of the drawbacks in using GAC are that the version of .NET Framework installed in the system where GAC is used and the one used for compiling the application need to be same. Also, strong names cannot be applied to assemblies (like third party code) on which the assemblies residing in the GAC folder depend upon.
Share this: