技术无极限

Nio的技术空间
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
9Apr/10

Oracle Exception: Could not load file or assembly ‘Oracle.DataAccess, Version=2.111.7.20…

Last week, I was having performance issues with my workstation. I was told to remove unused files and applications. I had previously installed ODAC 11g for the Oracle Data Providers. After realizing they were not backwards compatible with the Oracle10g providers we're using in production, I removed ODAC 11g using the Oracle Universal Installer. Apparently, that doesn't completely remove references to the 11g client or components.

After removing files and directories, I began receiving the following error when accessing an application locally:

1 Exception message: Could not load file or assembly 'Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

To see what Oracle libraries are installed in the GAC, I ran the following command from a Visual Studio command prompt:

1 gacutil /l | find /i "Oracle" > c:\Scripts\oracle.txt

This gave me the following list (note: Oracle 2.111.7.20 libraries are installed by ODAC 11g)

01 Oracle.DataAccess, Version=2.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86
02   Oracle.Management.Omo, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86
03   Oracle.VsDevTools, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86
04   Oracle.Web, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86
05   Policy.2.102.Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86
06   System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86
07   Oracle.DataAccess, Version=1.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342
08   Oracle.DataAccess, Version=1.102.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342
09   Oracle.Management.Omo, Version=1.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342
10   Oracle.VsDevTools, Version=1.102.2.20, Culture=neutral, PublicKeyToken=89b483f429c47342
11   Policy.1.102.Oracle.DataAccess, Version=1.102.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342
12   Policy.10.1.Oracle.DataAccess, Version=1.102.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342
13   Policy.10.2.Oracle.DataAccess, Version=1.102.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342
14   Policy.9.2.Oracle.DataAccess, Version=1.102.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342
15   System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

I have spent a week trying to figure out why these libraries wouldn't uninstall from the GAC and why I couldn't possibly remove them from the Oracle Universal Installer.

To manually uninstall these libraries, you'll have to run the following commands from a Visual Studio Command Prompt:

1 gacutil /u "Oracle.Management.Omo, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86"
2 gacutil /u "Oracle.VsDevTools, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86"
3 gacutil /u "Oracle.Web, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86"
4 gacutil /u "Policy.2.102.Oracle.DataAccess, Version=2.111.7.20, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86"

Here's the part that got me: I installed ODT, not just ODAC. This comes with a number of add-ons for Visual Studio (including Health Monitoring and Profiling). So, you have to manually edit the machine.config to get everything completely removed.
So,
Edit C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config and remove all references from the above libraries.

After following these steps, I was finally able to load the application locally using the ODAC/ODP.NET libraries for Oracle 10g.