Techemistry Blog

Windows Server 2008 Install DLL into GAC

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

<p>So first I want to say this has driven me crazy for days on end (an hour here, an hour there. &nbsp;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. &nbsp;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).</p> <p><br /> </p> <p>There are three (err four) solutions I discovered along the way that you might find helpful.</p> <p><br /> </p> <strong> 1.) Oh, Yes, You Can (Drag &amp; Drop) </strong><br /> <p>Give this trick a shot. &nbsp;Launch the Command Prompt with Admin privileges. &nbsp;From the command prompt, run "explorer C:\windows\assembly". &nbsp;Then from cmd, also run "explorer C:\". &nbsp;Next use the C:\ explorer to find the DLL(s) you need to deploy. &nbsp;Lastly, drag and drop the DLL file(s) into the C:\windows\assembly explorer window you launched from the admin cmd prompt. &nbsp;This has worked on occasion for me.&nbsp;</p> <p><br /> </p> <p><strong>2.) Oh, Yes, You Can (Drag &amp; Drop) Revisited</strong><br /> 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. &nbsp;Try this: Open Local Security Policy editor, navigate to Security Settings -&gt; Local Policies -&gt; Security Options, then find the policy called "User Account Control: Run all administrators in Admin Approval Mode". &nbsp;Disable this, restart, do your drag and drop, re-enable the policy, restart and you are home free. &nbsp;REMEMBER TO RE-ENABLE THE POLICY. &nbsp;Obvious draw back is having to restart the server twice to simply install DLL file(s) into the GAC.</p> <p><strong><br /> </strong></p> <p><strong>3.) Give ClickOnce The Boot<br /> </strong>ClickOnce does not have the ability to deploy DLL file(s) to the GAC. &nbsp;It just doesn't. &nbsp;The alternative here would be to deploy your application as using .MSI or something similar. &nbsp;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. &nbsp;Food for thought if you're in a pinch.</p> <p><br /> </p> <p><strong>4.) Use Their GAC Installer (DUH)</strong><br /> 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. &nbsp;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. &nbsp;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.</p> <p><br /> </p> <p>What about gacutil.exe? &nbsp;Well, I tried. &nbsp;I don't want the .NET SDK or Visual Studio installed on my client machines or the server. &nbsp;I tried copying the .exe and .config file to the server, read page after page of gacutil.exe manuals, and attempted numerous times. &nbsp;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. &nbsp;</p> <p><br /> </p> <p>Just when I thought I'd never have to deal with DLL HLL again.<br /> Happy Programming,&nbsp;</p> <p>~TK</p>

[return to articles list]