Friday 30 September 2011

How to add and remove an assembly from GAC?


                          Each computer that .NET is installed on has a Global Assembly Cache (GAC) located in the Assembly folder in the Windows directory (usually: C:\WinNT\Assembly). The GAC contains information about shared assemblies which are components that can be shared among several applications (Ex. a DLL). Shared assemblies must have globally unique names derived from their strong names (public keys generated to distinguish assemblies from other assemblies that may have the same names) which is Microsoft's solution to DLL hell. The GAC, not the registry, is the store for this information. When an application loads the GAC is examined by the Common Language Runtime to determine if the version of a shared component exists that is compatible with the one referenced by the application.
                          The gacutil.exe that ships with .NET can be used to add or remove a shared assembly from the GAC.

To add a shared assembly, from the command line enter:
    gacutil.exe /i myassembly.dll
To remove a shared assembly, from the command line enter:
    gacutil.exe /u myassembly.dll
When viewing the GAC in Windows Explorer shfusion.dll is used to provide the user interface. You can locate and rename this DLL to view the GAC like any other folder

No comments:

Post a Comment