Drag and drop a DLL to the GAC ("assembly") in windows server 2008 .net 4.0

TizzyFoe picture TizzyFoe · Oct 16, 2011 · Viewed 132.7k times · Source

I've trying to deploy some code to a client machine, where I don't want to install MS windows SDK tools. This means don't have access to "gacutil". I also have not created an installer for my code. It seems that these might be the only two options in .net 4.0.

In the past I would simply go to start, run, type "assembly", and drag and drop my dll in.

Is this no longer possible? When I try to do this I get no error message, but the dll doesn't appear in the "assembly" folder. When I use gacutil on my dev machine it works properly, but the dll still doesn't appear.

Answer

TizzyFoe picture TizzyFoe · Oct 17, 2011

In .net 4.0 Microsoft removed the ability to add DLLs to the Assembly simply by dragging and dropping.

Instead you need to use gacutil.exe, or create an installer to do it. Microsoft actually doesn’t recommend using gacutil, but I went that route anyway.

To use gacutil on a development machine go to:
Start -> programs -> Microsoft Visual studio 2010 -> Visual Studio Tools -> Visual Studio Command Prompt (2010)

Then use these commands to uninstall and Reinstall respectively. Note I did NOT include .dll in the uninstall command.
gacutil /u myDLL
gacutil /i "C:\Program Files\Custom\myDLL.dll"

To use Gacutil on a non-development machine you will have to copy the executable and config file from your dev machine to the production machine. It looks like there are a few different versions of Gacutil. The one that worked for me, I found here:
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\gacutil.exe.config

Copy the files here or to the appropriate .net folder;
C:\Windows\Microsoft.NET\Framework\v4.0.30319

Then use these commands to uninstall and reinstall respectively
"C:\Users\BHJeremy\Desktop\Installing to the Gac in .net 4.0\gacutil.exe" /u "myDLL"

"C:\Windows\Microsoft.NET\Framework\v4.0.30319\gacutil.exe" /i "C:\Program Files\Custom\myDLL.dll"