Sunday, October 20, 2013

How to Remove an Assembly from GAC using gacutil in Windows Server 2008 r2 (Without using .net sdk)

Hi all, I happened to remove some unwanted dlls from the GAC in a production server. In this server I didn't have windows SDK installed and therefore I had to use some other method to use gacutil.

The first thing I did was to copy the gacutil and it's configuration file from my local machine. It's located in C:\Program Files\Microsoft SDKs\Windows\v7.0A\Bin\.  Copy the gacutil Application and gacutil.exe CONFIG file from there and paste it to a folder in your Server. 

When you want to install  an assembly to GAC, copy the above files to your assembly location and open the cmd as an Administrator. Then run the command "gacutil -i <assembly_name>" to install the assembly.

To uninstall an assembly from GAC you have to use "gacutil -u" command. As gacutil is now in a sepereate folder in your server, redirect to that location from the cmd and use the above command. Here you have to use the fully qualified name of the assembly in the GAC. Following is an example. 

gacutil -u "hello,Version=1.0.0.0, Culture=neutral, PublicKeyToken=0123456789ABCDEF"

When you uninstall the assembly, you'll get an error message including this line. 

"Unable to uninstall: assembly is required by one or more applications"

To solve this follow the instructions as follow. 


  1. cd %systemroot%\assembly\
  2. cd gac_msil (Fom here you may have more that one "gac" directory, so you will have to search within each to find your component.  For me, it is within the "gac_MSIL" directory.)
  3. cd <assembly DLL name>
  4. cd <assembly version number>__<public key token>                                                            
    1. For example: 1.0.23.456__10dbd0fba6984148
  5. erase *.*
  6. Say "y" to are you sure.
  7. cd ..
  8. rd <assembly version number>__<public key token>
  9. cd ..
  10. rd <assembly DLL name>

No comments:

Post a Comment