Deploying Shared Components to the Global Assembly Cache

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1

If you plan to share a component between two or more applications on your Web server, you must deploy the component to the server's computer-wide code cache, called the global assembly cache. Each computer on which the common language runtime is installed has a global assembly cache. The global assembly cache stores assemblies that are shared by several applications on the computer. For more information, see the "Global Assembly Cache" topic in .NET Framework Help.

You should share assemblies by installing them into the global assembly cache only when you need to. As a general guideline, keep assembly dependencies private and locate assemblies in the application directory unless sharing an assembly is explicitly required. Assemblies do not have to be in the global assembly cache to be accessible to COM interop or unmanaged code.

Note

There are scenarios in which you should not install an assembly into the global assembly cache. If you place one of the assemblies that make up an application in the global assembly cache, you can no longer replicate or install the application by using the XCOPY tool to copy the application directory. You must move the assembly in the global assembly cache as well.

There are two ways to install an assembly into the global assembly cache:

  • Using Microsoft Windows Installer 2.0.

    This is the recommended and most common way to add assemblies to the global assembly cache. The installer provides reference counting of assemblies in the global assembly cache, plus other benefits. The only time you should not use the installer is when you are installing to a development or test server.

  • Using the Global Assembly Cache tool (Gacutil.exe).

    You can use Gacutil.exe to add strong-named assemblies to the global assembly cache and to view the contents of the global assembly cache.

Note

Gacutil.exe is only for development purposes and should not be used to install production assemblies into the global assembly cache.

For more information, see the "Global Assembly Cache Tool (Gacutil.exe)" topic in .NET Framework Help.

Procedures

To install a strong-named assembly into the global assembly cache

  1. From the Start menu, click Run, type cmd, and then click OK.

  2. At the command prompt, type the following command:

    gacutil -i <assemblyname>

Note

In this command, assembly name is the name of the assembly to install in the global assembly cache.

The following example installs an assembly with the file name Hello.dll into the global assembly cache.

gacutil -i Hello.dll

The .NET Framework SDK also provides a Windows shell extension called the Assembly Cache Viewer (Shfusion.dll), which you can use to drag and drop assemblies into the global assembly cache.