Techemistry Blog

Windows Server 2008 Install DLL into GAC

1/23/2015 8:48:00 PM -- Ted Krapf

So first I want to say this has driven me crazy for days on end (an hour here, an hour there.  If you're here, you already have discovered that you can no longer (simply) drag and drop dll files into C:\windows\assembly and have them installed auto-magically into the windows Global Assembly Cache.  Also sadly, you may have discovered that you can't deploy dll files into the GAC from a ClickOnce application (understandably why, but still annoying).

There are three (err four) solutions I discovered along the way that you might find helpful.

1.) Oh, Yes, You Can (Drag & Drop)

Give this trick a shot.  Launch the Command Prompt with Admin privileges.  From the command prompt, run "explorer C:\windows\assembly".  Then from cmd, also run "explorer C:\".  Next use the C:\ explorer to find the DLL(s) you need to deploy.  Lastly, drag and drop the DLL file(s) into the C:\windows\assembly explorer window you launched from the admin cmd prompt.  This has worked on occasion for me. 

2.) Oh, Yes, You Can (Drag & Drop) Revisited
Apparently the reason you can't drag and drop (even if you are logged in as an Administrator) is because there is a Local Security Policy that prevents it.  Try this: Open Local Security Policy editor, navigate to Security Settings -> Local Policies -> Security Options, then find the policy called "User Account Control: Run all administrators in Admin Approval Mode".  Disable this, restart, do your drag and drop, re-enable the policy, restart and you are home free.  REMEMBER TO RE-ENABLE THE POLICY.  Obvious draw back is having to restart the server twice to simply install DLL file(s) into the GAC.

3.) Give ClickOnce The Boot
ClickOnce does not have the ability to deploy DLL file(s) to the GAC.  It just doesn't.  The alternative here would be to deploy your application as using .MSI or something similar.  I'm a fan of ClickOnce and didn't want to go through the trouble, but theoretically you could just create an MSI that installs your GAC required DLL files I suppose.  Food for thought if you're in a pinch.

4.) Use Their GAC Installer (DUH)
In my case some of the DLL(s) that I needed deployed to the GAC were already part of an MSI from a third party.  Obviously this wouldn't be a good option if you were deploying to many clients, but in my case I'm mainly deploying to a small number of clients or a server.  I simply, using the library provider's MSI, installed their library on my server and low and behold it added everything I'd ever need to the GAC.

What about gacutil.exe?  Well, I tried.  I don't want the .NET SDK or Visual Studio installed on my client machines or the server.  I tried copying the .exe and .config file to the server, read page after page of gacutil.exe manuals, and attempted numerous times.  In the end I just couldn't get it to actually install the DLL file(s) into the GAC - even though it said it did.  

Just when I thought I'd never have to deal with DLL HLL again.
Happy Programming, 


[return to articles list]