简体   繁体   English

如何从服务器GAC中删除.NET程序集DLL

[英]How to remove .NET assembly DLLs from server GAC

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. 我正在尝试将包含Oracle ODP.NET库的VS2013项目部署到Windows 2008 IIS服务器,并从程序集“Oracle.ManagedDataAccess,Version = 4.121”收到错误“无法加载类型'OracleInternal.Common.ConfigBaseClass'。 2.0。“”我在网上发现的这是由项目的ODP与GAC中具有ODP的服务器之间的冲突引起的。 Instructions are then to remove ODP from the GAC. 然后,说明将从GAC中删除ODP。 There are Oracle DLLs in the GAC on the server. 服务器上的GAC中有Oracle DLL。 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. 我们99%确定这些DLL在之前尝试在该盒子上设置Oracle的时候已经在GAC中出现了,因为该服务器上的其他任何项目都不应该使用Oracle。 So we should be safe removing it from the GAC. 因此,我们应该安全地将其从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? 那么如何在服务器上没有gacutil.exe的情况下从GAC卸载Oracle DLL呢? 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? 或者我们是否需要将gacutil.exe从我的工作站复制到服务器才能执行此操作? Or is there another approach? 或者还有另一种方法吗? (preferably not involving registry edits) (最好不涉及注册表编辑)

Any advice appreciated, thanks. 任何建议表示赞赏,谢谢。

You should be able to do it from using the Windows interface as follows providing you have administrator privileges. 如果您具有管理员权限,则应该可以使用Windows界面进行以下操作。

  1. Navigate to the GAC, which is located at %systemdrive%\\Windows\\Assembly. 导航到GAC,它位于%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. 如果您无法通过上述方法卸载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中的所有文件进行交互。

If you have Visual Studio at all, anywhere, you can port gacutil onto the server from its location. 如果您在任何地方都有Visual Studio,则可以从其位置将gacutil移植到服务器上。 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 . 在我的计算机上,使用Visual Studio 2015,它位于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). 关于SO的另一个问题,它说你也可以单独安装Microsoft SDK(它应该安装在那里,我假设,或者在不同的“ v ”文件夹中,如果它是不同的版本)。 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 gacutil中找到它,然后将它和应该在它旁边的gacutil.exe.config文件复制到服务器。 ( where is gacutil.exe? ) 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? ). 当您尝试使用gacutil从GAC中删除Oracle.ManagedDataAccess时,有时会出现错误,Windows Installer是依赖项( 无法从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. 如果是这样,您还必须从HKEY_CURRENT_USER\\Software\\Microsoft\\Installer\\Assemblies\\Gl‌​obalHKEY_LOCAL_MACHINE\\Software\\Classes\\Installer\\Assemblies\\Glo‌​bal删除它,然后执行gacutil -u命令。 I had this issue and I didn't have to go to the HKCU location-but it was at the HKLM location. 我有这个问题而且我没有去过HKCU的位置 - 但它是在HKLM的位置。 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. 从那里删除后,我卸载并重新安装了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. 注意:当我尝试使用C:\\Windows\\assembly\\GAC_MSIL ,我甚至从未见过Oracle.ManagedDataAccess,因此我无法以这种方式删除它。 I'm posting this to help anyone that might run into stubborn DLLs that have the same issue. 我发布这个是为了帮助任何可能遇到具有相同问题的顽固DLL的人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM