How to remove .NET assembly DLLs from server GAC

39,846

Solution 1

You should be able to do it from using the Windows interface as follows providing you have administrator privileges.

  1. Navigate to the GAC, which is located at %systemdrive%\Windows\Assembly.

  2. Right-click each assembly file that is included in your application, click Uninstall, and then click Yes to confirm

If you are unable to uninstall the dlls via the above method you can access the GAC folder without the special view by opening a run command and entering the path below and hitting enter.

C:\Windows\assembly\GAC_MSIL

This will allow you to interact with all the files in the GAC as a normal folder.

Solution 2

If you have Visual Studio at all, anywhere, you can port gacutil onto the server from its location. On my computer, with Visual Studio 2015, it's at C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools. On another question here on SO, it said you can also just install the Microsoft SDK separately (and it should install there, I assume, or in a different "v" folder if it's a different version). If you know it should be on a particular computer, you can do where gacutil to find it, then copy it, and the gacutil.exe.config file that should be next to it, to the server. ( where is gacutil.exe? )

Sometimes you get an error when you try to remove Oracle.ManagedDataAccess from the GAC using gacutil, that Windows Installer is a dependency ( Unable to uninstall an Assembly from GAC? ). If so, you have to also remove it from HKEY_CURRENT_USER\Software\Microsoft\Installer\Assemblies\Gl‌​obal & HKEY_LOCAL_MACHINE\Software\Classes\Installer\Assemblies\Glo‌​bal, then do the gacutil -u command. I had this issue and I didn't have to go to the HKCU location-but it was at the HKLM location. After removing it from there, I uninstalled & re-installed the Oracle Developer Tools for Visual Studio, just to be safe (I saw it said to do so here: https://community.oracle.com/thread/3944905), then my project finally worked.

Note: When I tried going to C:\Windows\assembly\GAC_MSIL, I never even saw Oracle.ManagedDataAccess, so I could not remove it that way. I'm posting this to help anyone that might run into stubborn DLLs that have the same issue.

Share:
39,846
DaveCan
Author by

DaveCan

Updated on July 22, 2022

Comments

  • DaveCan
    DaveCan almost 2 years

    I'm trying to deploy a VS2013 project containing the Oracle ODP.NET library to a Windows 2008 IIS server, and receive an error "Could not load type 'OracleInternal.Common.ConfigBaseClass' from assembly 'Oracle.ManagedDataAccess, Version=4.121.2.0.'" From what I've found online this is caused by a conflict between the project's ODP and the server having ODP in the GAC. Instructions are then to remove ODP from the GAC. There are Oracle DLLs in the GAC on the server. We are 99% certain that the DLLs wound up in the GAC from a prior attempt to set up Oracle on that box a while back, as no other projects on that server should be using Oracle. So we should be safe removing it from the GAC.

    However, gacutil.exe is only available in Visual Studio, and we are not allowed to install Visual Studio onto the server.

    So how do we uninstall the Oracle DLLs from the GAC without having gacutil.exe available on the server? Can we just delete them from the directory? Or do we need to copy over gacutil.exe from my workstation to the server in order to do this? Or is there another approach? (preferably not involving registry edits)

    Any advice appreciated, thanks.

  • DaveCan
    DaveCan over 8 years
    Ok awesome thanks. He does have an uninstall option in that folder, didn't realize it would be that simple. So is it reversible just as easily? He has already copied the target DLLs to another folder. After uninstalling from the GAC, if we encounter some unforeseen issue can he just drag/drop them back to the GAC then right-click to install them? No other steps required? Or would we need to run/rerun the Oracle ODP.NET installer? He is nervous about removing them from the production server without a definite recovery plan, which is perfectly reasonable. Thanks.
  • benni_mac_b
    benni_mac_b over 8 years
    @DaveCan You can simply drag and drop a dll into the Assembly folder and that will install it no right click needed. Administrator privileges required as usual. You can test the process on your local machine in terms of the steps. You can always try another dll on the production server if nervous. Good Luck.
  • Eric Bole-Feysot
    Eric Bole-Feysot over 7 years
    Windows 10: C:\Windows\Microsoft.Net\assembly\GAC_MSIL
  • Adam W
    Adam W about 7 years
    I'm getting "Access is denied" when I try to uninstall Oracle.DataAccess or Oracle.Web from C:\Windows\assembly. I tried to run Explorer "as Administrator" but got same messsage
  • Adam W
    Adam W about 7 years
    Got it. That command "C:\Windows\assembly\GAC_MSIL" allowed me to delete 2 folders and old assembly is gone. Thanks
  • TechnoCore
    TechnoCore over 5 years
    I have Oracle.DataAccess and Oracle.Web in C:\Windows\assembly, uninstalling says access denied. Neither of them are in "C:\Windows\assembly\GAC_MSIL", no clue how to remove these assemblies