What is Global Assembly Cache (GAC)?
The global assembly cache (GAC) is a folder in the Windows directory that stores .NET assemblies that are specifically designed to be shared by all applications running on a system.
The concept of GAC is the result of the .NET architecture, the design of which addresses the problem of the 'DLL hell' that existed in COM (Component Object Model). Unlike COM, the assembly in GAC does not need to be registered before it can be used. Each assembly is accessed globally without any conflict by identifying its name, version, architecture, culture, and public key.
The GAC is a machine-wide code cache used for parallel execution of assemblies. The GAC implements the shared library function, in which different applications reuse the code placed in the files in a common folder. In .NET 4.0 the default location is: % windir% Microsoft.NET assembly
The GAC is also the first in the search path when loading a .NET assembly. The only requirement for an assembly to be deployed in GAC is that it should have a strong name. The common language runtime (CLR) references an assembly based on a specific version mentioned by the calling application. The GAC virtual file system helps in getting the version specific assembly.
The two tools associated with GAC are GAC Tool (gacutil.exe) and Assembly Cache Viewer (shfusion.dll). GAC Tool is used to check the existence of an assembly, register a shared assembly, view and edit the contents of GAC. Administrator rights must be used as the system folder. The Assembly Cache Viewer is used to view the details (version, culture, etc.) associated with the assemblies that are cached.
GAC offers the advantages of code reuse, file security (because it is installed in the 'systemroot' directory and therefore can only be deleted by users with administrative privileges), side-by-side execution (multiple versions of an assembly can be managed in the same folder ) ), Etc.
One of the drawbacks to using GAC is that the version of the .NET Framework installed on the system using GAC and the version used to compile the application must be the same. Also, strong names cannot be applied to assemblies (such as third-party code) that the assemblies in the GAC folder depend on.