What is GAC?

By | January 25, 2018

​GAC (Global Assembly Cache)

GAC contains strong named assemblies.
Assemblies in the GAC can be shared by all applications running on that machine, without having to copy the assembly local
It is recommended to install an assembly into GAC,only when required and shared by applications, otherwise they should be kept private

Advantages of using GAC:
-Shared location.
-File security.
-Side-by-side versioning.
-Additional search location

Note:You should not add an assembly into GAC,if you wish to deploy your application to another machine using XCopy deployment.

This is because in XCopy deployment, we only copy the application files to the target machine and not the GAC contents

XCopy: Deployment is simply copying files from one location to another

CopyLocal->true = copy that assembly locally into the bin folder of this controller application

System assemblies ->CopyLocal(false)=all the assemblies that are present in the gac,a copy of that assembly will not be made into the bin folder of that particular application
So advantage of installing an assembly into the GAC you can potentially share that assembly with multiple applications without having to have a copy of that assembly in each of the projects where you want to use

GAC path = C:\Windows\Assembly
In .NET 4.0 we have 2 GAC
1.C:\Windows\Assembly for .net 2.0 and 3.5 assemblies
2:C:\Windows\Microsoft.NET\Assembly for .NET 4.0 asssemblies

There are 2 ways to install assembly into GAC

1.Simply drag and drop
2.Use GacUtil.exe(GAC Utility toolgacutil.exe -i "your_dll_path")

Remove from Global Assembly Cache
gacutil.exe -i "your_dll_path"

 

Leave a Reply

Your email address will not be published. Required fields are marked *