The Global Assembly Cache (GAC: Global Assembly Cache) is used to store strongly-named assemblies that may be used for multiple times. When the main program needs to load the assembly, it first chooses to go to the Global Assembly Cache to find the required assembly.
Why is Global Assembly Cache required?
Assume that program a references assembly B, and program C also references assembly B. In this case, it is wise to put assembly B in a Global Assembly cache.
□Use global cache assembly
→ Delete All DLL and exe files in the as folder of drive F
→ Compile cow. cs into an assembly
→ Store the created farm. dll in the global assembly cache.
The error message is that a non-strong-name assembly cannot be saved to the Global Assembly Cache.
→ Re-compile cow. cs. Use the key this time.
→ Store farm. dll in the Global Assembly Cache again
If you want to extract a strong-name Assembly from the global cache: gacutil-u farm
→ Compile mainclass. cs into an executable file and reference farm. dll
→ Open mainclass. CS in notepad, modify as follows, and save
using System;
class MainClass
{ static void Main()
{ Cow.Moo();
Cow.Moo();
Cow.Moo();
}
}
→ Compile mainclass. CS again to reference the farm. dll that is already in the global assembly cache.
→ Delete farm. dll from the as folder because it has been stored in the Global Assembly Cache
Then run mainclass.exeand anothermainclass.exe again.
It indicates that farm. dll is already in the global assembly cache.
□Where is the global cache assembly?
In the "C: \ WINDOWS \ microsoft. Net \ Assembly \ gac_msil \ farm \ v4.0 _ 3.3.3.3 _ 863de8402b3a9978" folder
Summary:
○ When an assembly may be referenced multiple times, you can consider putting the Assembly into the global assembly cache.
○ Custom assembly and. Net default assembly are all placed in the Global Assembly Cache folder "C: \ WINDOWS \ Microsoft. NET \ Assembly \ gac_msil"
○ C # The Compiler first takes priority in the global assembly cache to find the Assembly
C # Assembly generation 11, Global Assembly Cache