16

Typically what I used to do is drag and drop the files onto the GAC folder.
This works in Windows 2000 & 2003, however when I try to do this in Windows Server 2008 I get 'Access is denied'.

The user that is doing this is a local administrator.

The only reference I can find to this is: Forum link

Is there another way to achieve this?

Note: I tried running explorer as the administrator, but I get the same error.

Edit: Ideally whatever solution there is should not turn off UAC, or install any software development kit. (So it can be applied to production servers).

Edit: Does anyone have anymore thoughts on this? I've currently on gone with disabling UAC in dev, however this is unacceptable in live.

starblue
  • 55,348
  • 14
  • 97
  • 151
Bravax
  • 10,453
  • 7
  • 40
  • 68

7 Answers7

21

This is a UAC issue in server 2008, some people have recommended stopping UAC, I would not recommend this on a production server. The answer is to use gacutil.

You do not need to install the SDK to run this on a production server, the exe and its config file can be deployed from a development machine (and removed after use if desired).

Place gacutil.exe and gacutil.exe.config into the WINDOWS\Microsoft.NET\Framework\ folder specific to the version of the framework you are using.

Then start a new instance of the command line using "Run as administrator"

Navigate to the C:\WINDOWS\Microsoft.NET\Framework.... folder where you have deployed gacutil

Then run: gacutil.exe /i

Hopefully this should resolve your issue (it has worked for me).

Good luck.

ahin4114
  • 483
  • 3
  • 5
  • 1
    A (not very helpful) note: 'Gacutil.exe is only for development purposes and should not be used to install production assemblies into the global assembly cache.' - http://msdn.microsoft.com/en-us/library/dkkx7f79.aspx – nicodemus13 Mar 13 '12 at 13:35
  • 3
    This worked for me. Microsoft says you shouldn't use Gacutil.exe in prod but the other tools they suggest are outdated/don't exist. If I'm deploying a web app I'm not going to build an installer just to put an assembly in the GAC. It's frustrating when they don't leave you an option. – Peter May 25 '12 at 14:47
4

Go to visual studio or .NET command prompt and type the command:

gacutil -if "fullpathhere.dll"

explore gacutil command more. -IF means install forcefully, there are other options as well.

If there is no Visual Studio or .NET Framework SDK installed, then you will not have the .NET command prompt. In that case, I think you will have to turn off the UAC from Control Panel to drag-drop an Assembly into the Assembly folder.

Aamir
  • 14,882
  • 6
  • 45
  • 69
  • Thanks for the feedback but, visual Studio will never be installed on these servers. I'll look into the gacutil method. – Bravax Jan 09 '09 at 11:09
  • Surely there's a better approach then that? Wouldn't that mean that every time we need to update the GAC we need to turn off the UAC, reboot make the change, then turn it back on, and reboot again? – Bravax Jan 09 '09 at 11:28
  • Yes and the better approach is to have .NET framework SDK installed. A normal user will not be playing with GAC, right? So, if you want to play with GAC, you need to have the privileges to do so. .NET command prompt simply provides you those privileges. – Aamir Jan 09 '09 at 11:56
  • And further, in Windows 2008 even a Local System Administrator needs some extra privileges to do certain things. Adding an assembly to GAC is one of those things. – Aamir Jan 09 '09 at 11:57
  • Ok, but that would mean that at some point we'll need to install the .net framework sdk on a production server. Isn't that a bad idea? – Bravax Jan 09 '09 at 12:00
  • Shouldn't it be enought to issue the above command from an elevated command prompt? A reboot or switching off UAC should not be required. – Dirk Vollmar Jan 09 '09 at 13:59
  • Sure, but in order to issue the command I need to install the SDK which I definately don't want to do on a production server. – Bravax Jan 09 '09 at 14:20
  • What a nightmare. I would seriously question the "security" reasoning behind either forcing the UAC to be turned off or installing the full SDK on a production box. – NotMe Jan 09 '09 at 19:56
  • The '/if' switch has changed in the latest versions of gacutil, now it is listed as an alias to '/i' so I assume the functionality it the same, I have listed more complete steps to resolve this in my answer. – ahin4114 Apr 29 '09 at 10:23
3

The trick explained by Paulo Oliveira works but not in all circumstances. On Windows Server 2008 R2 I've already deployed the following tactic:

(ensure you're logged on with an account that has admin rights on the server)

  • open Local Security Policy (Start button, type "local"...)
  • navigate to Security Settings > Local Policies > Security Options
  • locate the policy called User Account Control: Run all administrators in Admin Approval Mode

You'll probably find that this policy in enabled. Disable it, reboot the server and now you should be able to use the regular drag & drop method.

Do not forget to enable this setting again when you're done.

(ref: http://blogs.msdn.com/b/mossbiz/archive/2010/06/10/add-an-assembly-to-the-global-assembly-cache-on-windows-server-2008-r2.aspx)

Valentino Vranken
  • 5,597
  • 1
  • 26
  • 28
2

Run a command prompt with "Run as Administrator". Execute command "explorer C:\windows\assembly". This window accepts drop of DLL's from another explorer executed with "Run as administrator privileges.

Hope it helps

Paulo Oliveira
  • 218
  • 1
  • 3
1

If you change the Local Security Policy on the Win2008 server (or Win7), you can use the old drag/drop method:

Link

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
ermurri
  • 11
  • 1
0

If its a 3.5 dll or older, drag drop into start / run / assembly. If its a 4.0 dll or newer, you should run gacutil and then look in windows / microsoft.net / assembly. For prod, just write a batch file and copy over the gacutil app for setup purposes. No need to install VS in prod.

Iturea
  • 1
0

I've never tried it in Windows Server 2008, but have you tried from Control Panel / Administrative tools / .NET Framework 2.0 Configuration ?

Eduardo Campañó
  • 6,778
  • 4
  • 27
  • 24
  • That doesn't exist on Windows Server 2008. (Well not in that location, or that I can find.) Sadly i'm new to Windows Server 2008 too... – Bravax Jan 09 '09 at 11:08
  • See this post: http://blogs.pointbridge.com/Blogs/pagnusat_tony/Pages/Post.aspx?_ID=13 , it's not a clean solution but it seems to work – Eduardo Campañó Jan 09 '09 at 11:19
  • Surely there's a better approach then that? Wouldn't that mean that every time we need to update the GAC we need to turn off the UAC, reboot make the change, then turn it back on, and reboot again? – Bravax Jan 09 '09 at 11:27
  • Installing the .NET Framework SDK and use the command Aamir suggests. Sorry I can't imagine anything else right now. – Eduardo Campañó Jan 09 '09 at 11:37