1.14 Manage the Global Assembly Cache


Problem

You need to add or remove assemblies from the global assembly cache (GAC).

Solution

Use the Global Assembly Cache tool (gacutil.exe) from the command line to view the contents of the GAC as well as to add and remove assemblies.

Discussion

Before you can install an assembly in the GAC, the assembly must have a strong name; see recipe 1.9 for details on how to strong name your assemblies. To install an assembly named SomeAssembly.dll into the GAC, use the command gacutil /i SomeAssembly.dll .

To uninstall the SomeAssembly.dll assembly from the GAC, use the command gacutil /u SomeAssembly . Notice that you don't use the .dll extension to refer to the assembly once it's installed in the GAC.

To view the assemblies installed in the GAC, use the command gacutil /l . This will produce a long list of all the assemblies installed in the GAC, as well as a listing of assemblies that have been precompiled to binary form and installed in the ngen cache. To avoid searching through this list to determine if a particular assembly is installed in the GAC, use the command gacutil /l SomeAssembly .

Note  

The .NET Framework uses the GAC only at run time; the C# compiler won't look in the GAC to resolve any external references that your assembly references. During development, the C# compiler must be able to access a local copy of any referenced shared assemblies. You can either copy the shared assembly to the same directory as your source code or use the /lib switch of the C# compiler to specify the directory where the compiler can find the required assemblies.




C# Programmer[ap]s Cookbook
C# Programmer[ap]s Cookbook
ISBN: 735619301
EAN: N/A
Year: 2006
Pages: 266

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net