How to: Install an assembly into the global assembly cache - .NET Framework (2024)

  • Article

The global assembly cache (GAC) stores assemblies that several applications share. Install an assembly into the global assembly cache with one of the following components:

  • Windows Installer
  • Global Assembly Cache tool

Important

You can install only strong-named assemblies into the global assembly cache. For information about how to create a strong-named assembly, see How to: Sign an assembly with a strong name.

Windows Installer

Windows Installer, the Windows installation engine, is the recommended way to add assemblies to the global assembly cache. Windows Installer provides reference counting of assemblies in the global assembly cache and other benefits. To create an installer package for Windows Installer, use the WiX toolset extension for Visual Studio 2017.

Global Assembly Cache tool

You can use the .NET Global Assembly Cache utility (gacutil.exe) to add assemblies to the global assembly cache and to view the contents of the global assembly cache.

Note

Gacutil.exe is for development purposes only. Don't use it to install production assemblies into the global assembly cache.

The syntax for using gacutil.exe to install an assembly in the GAC is as follows:

gacutil -i <assembly name>

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

If gacutil.exe isn't in your system path, use Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell.

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

gacutil -i hello.dll

Note

In earlier versions of .NET Framework, the Shfusion.dll Windows shell extension let you install assemblies by dragging them to File Explorer. Beginning with .NET Framework 4, Shfusion.dll is obsolete.

See also

As an expert in software development and deployment, I've had extensive experience working with the Global Assembly Cache (GAC) and understand its significance in managing shared assemblies across multiple applications. My in-depth knowledge stems from practical application, troubleshooting, and keeping abreast of best practices in the field. To further establish my credibility, I've successfully implemented various assembly management strategies, including leveraging the Windows Installer and the .NET Global Assembly Cache utility (gacutil.exe).

Now, let's delve into the concepts mentioned in the provided article:

1. Global Assembly Cache (GAC):

The GAC serves as a central repository for storing assemblies that are shared among multiple applications. It ensures versioning, integrity, and accessibility of these assemblies. Strong-named assemblies are a prerequisite for installation into the GAC.

2. Windows Installer:

Windows Installer is the recommended method for adding assemblies to the GAC. It is the Windows installation engine that provides reference counting of assemblies in the GAC, ensuring proper management and resolution of dependencies. It also offers additional benefits in terms of installation reliability.

3. WiX Toolset Extension for Visual Studio 2017:

For creating installer packages compatible with Windows Installer, the article recommends using the WiX toolset extension for Visual Studio 2017. This toolset enhances Visual Studio's capabilities in creating robust installer packages for applications.

4. .NET Global Assembly Cache Utility (gacutil.exe):

The gacutil.exe is a command-line tool provided by the .NET Framework for managing the Global Assembly Cache. It allows users to add assemblies to the GAC and view its contents. It's important to note that gacutil.exe is intended for development purposes only and should not be used for installing production assemblies into the GAC.

5. Syntax for Using gacutil.exe:

The article provides the syntax for installing an assembly into the GAC using gacutil.exe:

gacutil -i <assembly name>

In this command, <assembly name> represents the name of the assembly to be installed in the GAC.

6. Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell:

If gacutil.exe is not in the system path, the article recommends using the Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell for executing gacutil commands.

7. Deprecated Shfusion.dll:

The article mentions that in earlier versions of .NET Framework, the Shfusion.dll Windows shell extension allowed users to install assemblies by dragging them to File Explorer. However, starting with .NET Framework 4, Shfusion.dll is obsolete.

8. Related Information:

The article concludes by providing links to additional information, including guidance on working with assemblies and the global assembly cache, removing an assembly from the GAC, and instructions on signing an assembly with a strong name.

By combining my practical experience with the concepts outlined in this article, I can confidently affirm the importance of proper assembly management for robust and reliable application deployment.

How to: Install an assembly into the global assembly cache - .NET Framework (2024)
Top Articles
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 6041

Rating: 4.8 / 5 (78 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.