.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Imran Ghani
Sohaib Khalid

Home >> Articles >> .Net Framework >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Global Assembly Cache

Posted By:Karthikeyan Anbarasan       Posted Date: January 01, 2011    Points: 10    Category: .Net Framework    URL: http://www.dotnetspark.com  

All About Global Assembly Cache

If an assembly is to be accessed by multiple applications, the assembly must be placed into a
well-known directory, and the CLR must know to look in this directory automatically when a
reference to the assembly is detected. This well-known location is called the global assembly
cache (GAC), which can usually be found in the following directory (assuming that Windows
is installed in the C:\Windows directory):

The GAC directory is structured: It contains many subdirectories, and an algorithm is used to
generate the names of these subdirectories. You should never manually copy assembly files
into the GAC; instead, you should use tools to accomplish this task. These tools know the
GAC's internal structure and how to generate the proper subdirectory names.
While developing and testing, the most common tool for installing a strongly named assembly
into the GAC is GACUtil.exe. Running this tool without any command-line arguments yields
the following usage:

Microsoft (R) .NET Global Assembly Cache Utility. Version 4.0.20928.1
Copyright (c) Microsoft Corporation. All rights reserved.
Usage: Gacutil  [  ]
/i  [ /r <...> ] [ /f ]
Installs an assembly to the global assembly cache.
/il  [ /r <...> ] [ /f ]
Installs one or more assemblies to the global assembly cache.
/u  [ /r <...> ]
Uninstalls an assembly from the global assembly cache.
/ul  [ /r <...> ]
Uninstalls one or more assemblies from the global assembly cache.
/l [  ]
List the global assembly cache filtered by 
/lr [  ]
List the global assembly cache with all traced references.
Deletes the contents of the download cache
Lists the contents of the download cache
74 Part I CLR Basics
Displays a detailed help screen
Specifies a traced reference to install (/i, /il) or uninstall (/u, /ul).
Forces reinstall of an assembly.
Suppresses display of the logo banner

Suppresses display of all output
As you can see, you can invoke GACUtil.exe, specifying the /i switch to install an assembly
into the GAC, and you can use GACUtil.exe's /u switch to uninstall an assembly from the GAC.
Note that you can't ever place a weakly named assembly into the GAC. If you pass the file
name of a weakly named assembly to GACUtil.exe, it displays the following error message:
"Failure adding assembly to the cache: Attempt to install an assembly without
a strong name."
 Subscribe to Articles


Further Readings:


No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend