0

I want my application to use Oracle 11g ODAC, but it seems to be using those for 12c.... How can I force my application to use the 11g ODAC?

For some reason, I have following clients and ODT in my PC (Windows 7 Pro SP1 64-bit):

- Oracle 11g Client (64-bit) version 11.2.0.3.0
- Oracle 12c Client (64-bit) version 12.1.0.1.0
- Oracle 12c ODT (Oracle Developer Tools for Visual Studio) (32-bit)

And, my .net project (visual studio 2013) referes "Oracle.DataAccess.dll" which is stored in: C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342

The order of my environment path is like this:

C:\oracle12c\product\12.1.0\client_2;
C:\oracle12c\product\12.1.0\client_2\bin;
C:\oracle12c\product\12.1.0\client_1;
C:\oracle12c\product\12.1.0\client_1\bin;
C:\Oracle\product\11.2.0\client_1;
C:\Oracle\product\11.2.0\client_1\bin;

What I have tried is to specify dllPath in the web.config file like this:

<oracle.dataaccess.client>
    <settings>
        <add name="DllPath" value="C:\Oracle\product\11.2.0\client_1\bin"/>
    </settings>
</oracle.dataaccess.client>

However, it does not work. When the constructor of OracleConnection class is called, I get the following error:

System.TypeInitializationException: 
The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception. 
---> Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client
   at Oracle.DataAccess.Client.OracleInit.Initialize()
   at Oracle.DataAccess.Client.OracleConnection..cctor()
   --- End of inner exception stack trace ---

Any information will be helpful. Thank you in advance!

--- UPDATE Oct 14 by Yukapod ---

I've found that my application does not require 12c ODT 32-bit version, so I removed it from my PC and tried again. However, the situation has not changed; I still get the "The provider is not compatible with the version of Oracle client" error just after the constructor of OracleConnection class is called. I'm wondering where the problem is....

I still have the following configuration in my web.config:

<oracle.dataaccess.client>
    <settings>
        <add name="DllPath" value="C:\Oracle\product\11.2.0\client_1\bin"/>
    </settings>
</oracle.dataaccess.client>

And, this is my current environment PATH variable:

C:\oracle12c\product\12.1.0\client_1;
C:\oracle12c\product\12.1.0\client_1\bin;
C:\Oracle\product\11.2.0\client_1;
C:\Oracle\product\11.2.0\client_1\bin;

where

C:\oracle12c\product\12.1.0\client_1 
   -> ORACLE_HOME for Oracle 12c Client (64-bit) version 12.1.0.1.0
Oracle\product\11.2.0\client_1 
   -> ORACLE HOME for Oracle 11g Client (64-bit) version 11.2.0.3.0

And even I reversed the order of the PATH variable (I mean, make 11g come first), the result did not change (still have the same error). If anyone knows something, any kind of information will be very helpful. Thank you in advance again!

yukapod
  • 16
  • 4
  • Your application tries to use the 11g ODAC: C:\Windows\Microsoft.NET\assembly\GAC_64\Oracle.DataAccess\v4.0_4. **112**.3.0__89b483f429c47342. However, it loads the 64 bit version of "Oracle.DataAccess.dll" but then it finds (first) the 32 bit Oracle client binaries. If you like -or have to- use both 32 bit and 64 bit Oracle client on you machine, follow this instruction to install both of them: http://stackoverflow.com/questions/24104210/badimageformatexception-this-will-occur-when-running-in-64-bit-mode-with-the-32#24120100 – Wernfried Domscheit Oct 13 '15 at 07:51
  • Thank you for quick response, Wernfried! I've found that my application does not require 12c ODT 32-bit version anymore, so I removed it from my PC. However, the situation did not change... – yukapod Oct 14 '15 at 02:07
  • Have also a look at this: http://stackoverflow.com/questions/659341/the-provider-is-not-compatible-with-the-version-of-oracle-client#25412992. My recommendation is remove all your Oracle installations entirely (see here: http://stackoverflow.com/questions/28727721/how-can-i-completely-uninstall-oracle-11g/28728711#28728711) and make a new and fresh installation. – Wernfried Domscheit Oct 14 '15 at 06:45

1 Answers1

0

Thank you all for helping me out! I finally found the cause of this problem.

Cause:

12c's Policy DLL is redirecting all the reference for 11g to 12c.

Details:

I installed 11g client first and then installed 12c clients, so there are two policy folders in my GAC (C:\Windows\Microsoft.NET\assembly\GAC_64\Policy.4.112.Oracle.DataAccess):

v4.0_4.112.3.0__89b483f429c47342 <== policy folder for 11g
v4.0_4.121.1.0__89b483f429c47342 <== policy folder for 12c

In each folder you can see the Policy.[version].Oracle.DataAccess.config file.

The config file for 11g is like this:

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/>
            <bindingRedirect oldVersion="4.112.0.0-4.112.3.0" newVersion="4.112.3.0"/> <== This is OK!
        </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

And this is the one for 12c:

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <dependentAssembly>
          <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342"/>
            <bindingRedirect oldVersion="4.112.0.0-4.112.9999.9999" newVersion="4.121.1.0"/> <== OMG!! The 11g version 4.0_4.112.3 is included!
        </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>

I don't have to care for the order of the environment PATH variable, or I don't have to specify which version of Oracle.DataAccess.dll I want using DllPath. In my case, the followings are key points to use the specific ODAC:

- Make sure that my application has a reference for Oracle.DataAccess.dll for 11g.
- Remove / rename the policy folder for 12c (v4.0_4.121.1.0__89b483f429c47342) in GAC. 

And then, I could finally use 11g.

yukapod
  • 16
  • 4