如何从服务器 GAC 中删除 .NET 程序集 DLL
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33355114/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to remove .NET assembly DLLs from server GAC
提问by DaveCan
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.
我正在尝试将包含 Oracle ODP.NET 库的 VS2013 项目部署到 Windows 2008 IIS 服务器,并收到错误“无法从程序集“Oracle.ManagedDataAccess,版本 = 4.121”加载类型“OracleInternal.Common.ConfigBaseClass”。 2.0.'”从我在网上找到的内容来看,这是由项目的 ODP 与 GAC 中具有 ODP 的服务器之间的冲突引起的。然后是从 GAC 中删除 ODP 的说明。服务器上的 GAC 中有 Oracle DLL。我们 99% 肯定 DLL 中的 DLL 是在不久前尝试在该机器上设置 Oracle 时在 GAC 中结束的,因为该服务器上的其他项目不应该使用 Oracle。因此,我们应该安全地将其从 GAC 中删除。
However, gacutil.exe is only available in Visual Studio, and we are not allowed to install Visual Studio onto the server.
但是 gacutil.exe 只在 Visual Studio 中可用,我们不允许将 Visual Studio 安装到服务器上。
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)
那么我们如何在服务器上没有 gacutil.exe 的情况下从 GAC 卸载 Oracle DLL?我们可以从目录中删除它们吗?或者我们是否需要将 gacutil.exe 从我的工作站复制到服务器才能执行此操作?还是有另一种方法?(最好不涉及注册表编辑)
Any advice appreciated, thanks.
任何建议表示赞赏,谢谢。
回答by benni_mac_b
You should be able to do it from using the Windows interface as follows providing you have administrator privileges.
如果您具有管理员权限,您应该可以通过使用 Windows 界面来执行此操作,如下所示。
Navigate to the GAC, which is located at %systemdrive%\Windows\Assembly.
Right-click each assembly file that is included in your application, click Uninstall, and then click Yes to confirm
导航到位于 %systemdrive%\Windows\Assembly 的 GAC。
右键单击应用程序中包含的每个程序集文件,单击“卸载”,然后单击“是”进行确认
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.
如果您无法通过上述方法卸载 dll,则可以通过打开运行命令并输入下面的路径并按 Enter 来访问 GAC 文件夹,而无需特殊视图。
C:\Windows\assembly\GAC_MSIL
This will allow you to interact with all the files in the GAC as a normal folder.
这将允许您作为普通文件夹与 GAC 中的所有文件进行交互。
回答by vapcguy
If you have Visual Studio at all, anywhere, you can port gacutilonto 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 gacutilto find it, then copy it, and the gacutil.exe.configfile that should be next to it, to the server. ( where is gacutil.exe?)
如果您在任何地方都拥有 Visual Studio,则可以gacutil从其位置移植到服务器上。在我的计算机上,使用 Visual Studio 2015,它位于C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools. 关于SO的另一个问题,它说您也可以单独安装Microsoft SDK(我假设它应该安装在那里,或者v如果它是不同的版本,则安装在不同的“ ”文件夹中)。如果您知道它应该在特定计算机上,您可以where gacutil找到它,然后将它以及gacutil.exe.config它旁边的文件复制到服务器。(gacutil.exe 在哪里?)
Sometimes you get an error when you try to remove Oracle.ManagedDataAccessfrom 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 -ucommand. 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.
有时,当您尝试Oracle.ManagedDataAccess使用gacutilWindows Installer 是一个依赖项从 GAC删除时会收到错误消息(
无法从 GAC 卸载程序集?)。如果是这样,您还必须将其从HKEY_CURRENT_USER\Software\Microsoft\Installer\Assemblies\Gl??obal& 中删除HKEY_LOCAL_MACHINE\Software\Classes\Installer\Assemblies\Glo??bal,然后执行gacutil -u命令。我遇到了这个问题,我不必去 HKCU 位置,但它在 HKLM 位置。从那里删除后,为了安全起见,我卸载并重新安装了适用于 Visual Studio 的 Oracle 开发人员工具(我在这里看到它说这样做:https: //community.oracle.com/thread/3944905),然后我的项目终于成功了。
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.
注意:当我尝试转到 时C:\Windows\assembly\GAC_MSIL,我什至从未见过 Oracle.ManagedDataAccess,因此我无法以这种方式将其删除。我发布此信息是为了帮助可能遇到具有相同问题的顽固 DLL 的任何人。

