How do I force an assembly to uninstall from the GAC?

17,425

Solution 1

First, verify that your assembly is not locked by another process via gacutil.exe

gacutil /u WBRT.Configuration

If the above is OK make sure the file parent container has no permanent flag - Permanent="no"

<Component Shared="yes" Permanent="no" Guid="PUT-GUID-HERE" >
    <File Id="filB7155C3E9A241BEAFE09533364964732" KeyPath="yes" Assembly=".net" 
       Source="$(var.Configuration.TargetDir)\WBRT.Configuration.dll" />
</Component>

Solution 2

I followed the steps mentioned by @Mohsen , Remove the registry entry and uninstalled the DLL from GAC to resolve a conflict issue.

[HKLM\SOFTWARE\Classes\Installer\Assemblies\Global] and run gacutil /u dllname -And success. I do not know what is the side effect. It worked for me, then I ran

gacutil -u dllThatIWantedToRemove

Share:
17,425
Alex Angas
Author by

Alex Angas

Updated on June 04, 2022

Comments

  • Alex Angas
    Alex Angas almost 2 years

    I've developed a simple installation package using WiX that installs an assembly called WBRT.Configuration into the Global Assembly Cache (GAC). While the file installs, it is not removed when the package is uninstalled.

    I've tried running a command prompt as administrator, used msiexec /x specifying the msi filename and msiexec /x specifying the product code.

    With the /l*v switch, there is no error:

    Executing op: ActionStart(Name=MsiUnpublishAssemblies,Description=Unpublishing assembly information,Template=Application Context:[1], Assembly Name:[2]) Executing op: AssemblyUnpublish(,,AssemblyType=1,,AssemblyName=WBRT.Configuration,version="1.0.0.0",culture="neutral",publicKeyToken="361AD75BADC53912",processorArchitecture="MSIL",Descriptor=2-(xWui~z@UnhQuo-~Gh>S.OwM9Kim9x0ul%Ore=9) Executing op: ActionStart(Name=UnpublishFeatures,Description=Unpublishing Product Features,Template=Feature: [1])

    WiX File element

    <File Id="filB7155C3E9A241BEAFE09533364964732" KeyPath="yes" Assembly=".net" Source="$(var.Configuration.TargetDir)\WBRT.Configuration.dll" />

    MsiAssemblyName table in Orca

    MSIAssemblyName

    File in the GAC

    File in GAC

    Version tab of the file in the GAC

    Version

    I'm completely stumped. Does anyone have ideas?

  • Alex Angas
    Alex Angas over 12 years
    Gacutil gave the message Unable to uninstall: assembly is required by one or more applications. Process Explorer showed what processes were locking the DLL and ended them. The file then uninstalled correctly!
  • toha
    toha almost 7 years
    @AlexAngas : same with me. How to unlock the dependency?
  • toha
    toha almost 7 years
    Finally I delete my dll name key at [HKLM\SOFTWARE\Classes\Installer\Assemblies\Global] and run gacutil /u dllname -> And success. I do not know what is the side effect.
  • Mohsen Sichani
    Mohsen Sichani over 6 years
    @Toha, worked for me, then I ran gacutil -u dllThatIWantedToRemove