Safe to install production assemblies with gacutil.exe?

1.9k views Asked by At

MSDN states that gacutil.exe is not safe to use for production servers. Is there a legitimate reason for this or is Microsoft just practicing a little CYA? Is this warning safe to ignore? Or should I finally learn how to use Microsoft Windows Installer 2.0?

MSDN's exact wording:

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

2

There are 2 answers

1
John Ruiz On BEST ANSWER

Items in the global assembly cache are shared across programs.

When you use Gacutil to add an assembly to the cache, there will be no reference counting of items that depend on it. Therefore, it is possible that when you use GacUtil /U to remove your library from the cache, you will have broken other programs that depend on it.

In contrast, Windows Installer 2.0 keeps a count and will only remove libraries from the assembly cache when no other program requires it.

4
Hans Passant On

That's because gacutil.exe won't be available on the target machine. It is part of the Windows SDK, the .NET 4.0 version of it is located in C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools. You have it on your machine because you installed Visual Studio.

You simply do it with an installer. In a Setup project, right-click the File System pane, Add Special Folder and pick "Global Assembly Cache Folder". And put the DLL in there.