How to uninstall DLL from assembly folder? Permission denied when uninstalling DLL from GAC

18,865

Solution 1

This didn't work before, but thankfully did on my last attempt. Go figure...

I found gacutil.exe on the server and ran gacutil -u dllName.DLL Installing the new DLL was simply gacutil -i "PathAndFilenameOfNewDLL"

http://msdn.microsoft.com/en-us/library/zykhfde0%28VS.80%29.aspx

Solution 2

I know I'm late to the party, but here is another solution using Powershell if you do not have gacutil.exe present. Gacutil is a development tool and normally isn't present on production systems.

Fire up PowerShell using an elevated prompt by right-clicking on it and selecting "Run As Administrator." Then type or copy/paste the following:

$pathToFile = 'PathAndFilename.dll'
[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
$publish = New-Object System.EnterpriseServices.Internal.Publish
$publish.GacRemove($pathToFile)

If you want to install a copy to the GAC, change the last line to this:

$publish.GacInstall($pathToFile)

Solution 3

Put gacutil /u in a cmd file and run by right clicking and selecting Run As Administrator. This worked where everything else suggested failed.

Share:
18,865

Related videos on Youtube

SamErde
Author by

SamErde

Senior Systems Engineer working on Active Directory, Exchange, Citrix, VMware, Cisco UCS, Azure, Office 365, and other fun tech. Requires Jesus, coffee, PowerShell, and Oxford commas.

Updated on September 17, 2022

Comments

  • SamErde
    SamErde over 1 year

    I am trying to uninstall a DLL from the C:\Windows\Assembly "folder" on Windows Server 2008, but am getting a "permission denied" error. How do I go about removing a DLL without uninstalling the entire application?

    An application vendor has sent me new DLL's, with no instructions on how to remove the old version or add these new ones. Google hasn't been as helpful as usual, either...

    • Zoredache
      Zoredache over 13 years
      I am not sure, but perhaps you need to unregister it with regsrv32 and register the new one? Make sure try to use that from an elevated shell.
    • SamErde
      SamErde over 13 years
      This was on a 64-bit server, so that didn't work, either. Using \windows\syswow64\regsvr32 c:\filename.dll may be an option.
    • SamErde
      SamErde over 13 years
      Using regsvr32.exe or \windows\syswow64\regsvr32.exe would be an option for most DLL's, but I don't think it can uninstall from the GAC. I have posted my solution below.
  • BlueMonkMN
    BlueMonkMN almost 9 years
    A great and important solution for test systems where GacUtil is not available. Worked great for me once I realized how important the quotes around the DLL name are.