Managing the Windows Server 2008 GAC: Access Denied!

GAC / Server Management

We have decided to manage the bulk of our common assemblies in the GAC due to the simplicity it offers when needing to perform updates/bugfixes across many web applications using them.  This worked beautifully in Windows Server 2000/2003, however when we moved all of our servers over to Windows Server 2008R2 we got something that was a little bit unexpected…  When attempting to install/uninstall assemblies using the drag-and-drop functionality we’ve become familiar with when browsing C:Windowsassembly or using tools like the .NET Configuration Tool or GACView (all run as local admin in elevated mode!), we got the following error message:

Access Denied!

Now, apparently there are quite a few people who have experienced this problem; and unfortunately for us, none of the suggestions we found worked.  Though, this could have to do with the fact that we have a level 1 PCI certification and our servers are locked down tighter than a medieval chastity belt .oO

Note: When using GACUTIL from an elevated command prompt, everything works just fine.  However, it’s less than a desirable approach for our release managers who actually have to release the libraries.

The Solution

Simple.  I scowered the net reading up on how to modify the GAC programmatically.  Thankfully, I didn’t have to re-invent any wheels because this has already been done.  Using a combination of the ManagedFusion library by Simon Allaeys and the GACWrap samples by Junfen Zhang, I created this simple “GAC Manager” application which, when ran in elevated mode, solved our problems :-)

Here’s a screenshot:

What Does it Do?

  • Upon initial load, displays a list of all assemblies in the GAC.
  • You can filter based on a list of strings.  In the screenshot above, I have a filter with the string “CrystalDecisions”, so only assemblies whose assembly name contains “CrystalDecisions”.
  • The filter is remembered between application runs (it’s stored in the application settings, so it’s app.config dependant).
  • You can install one or many assemblies at the same time to the GAC.
  • You can remove one or many assemblies at the same time from the GAC.
  • You can replace a assembly in the GAC with another assembly (very useful for upgrading – basically just removes and adds).  Only use this when you are sure that you can safely remove the original assembly (e.g. there are no version-dependencies for the assembly). 

Disclaimer

This is a “one-hour” piece of software and I have not taken any extra time to clean it up, beautify it or what have you.  It is very important that you fully understand the implications of messing with the GAC and I cannot be held responsible for any damage that this might do to you, your company or your employer.  But, considering we use this in our production environments, you should be ok… I hope… ;-)

License

The license for the ManagedFusion library is included in the project file, and also viewable on its CodeProject page.  The GACWrap samples license is not stated in the blog post, however let it be known that I did not write nor do I own the contained within the GACWrap.cs file in the GAC Manager project.  Other than these exceptions, you can do what you want with the remaining code in the GAC Manager project.  If you make any useful improvements, maybe you might be so kind as to share them with me so that I can incorporate them into this post, or add a comment linking to where your updated version is :-)


Cyle


Programming enthusiast. I've been intrigued by computers since I was 12, staying in at recess to code QBASIC on the old Apple II. Background in the payment industry, particularly in card switching and related system architecture. Lover of high-performance distributed architecture. Huge fan of the new NoSQL wave. Open source fanatic.

Leave a Reply