Wednesday, 16 October 2019

GAC in .Net, step by step installation of library [Revision]

Reasons why we need to install an assembly into the global assembly cache:

  • Shared location: Various app can access through shared location.
  • File security: Administrator privileges required to manage GAC so no other can delete ii.
  • Side-by-side versioning: Multiple copies of assemblies with the same name but different version information can be maintained in the global assembly cache.

Let see how we can complete library installation in GAC easily.

1. If Visual Studio installed in system, find Developer Command Prompt and run as administrator.

2. Check gacutil command by listing all existing installed library by command line
gacutil -l

3. Search library by name using command line
gacutil -l <dll name>

4. Install dll by command line
gacutil -I <dll name along with full path>

5. Check again if newly added dll is available or not by using command
gacutil -l <dll name>

6. Delete/uninstall dll from GAC by using command
Gacgutil -u <dll name> 

1. Failure adding assembly to the cache: Administrator permissions are needed to use the selected options. Use an administrator command prompt to complete these tasks.

Solution: Re run developer command prompt as administrator.

2. Failure adding assembly to the cache: Strong name signature could not be verified.  Was the assembly built delay-signed?

Solution: Make sure you have created a strong name for your library and Delay sign only is partially checked.

3. Can we have multiple library installed with same name in GAC?
Answer: Yes, Name will be same but version will be different.

4. Can we install netstandard2.0 dll in to GAC?
Answer: Yes