0

Yes, I have checked the other similar questions, but none of them seem to match the problems I am having.

I have a 64-bit Windows client with 64-bit Oracle installed, but my app uses a library that requires a 32-bit Oracle client. I created a directory and put the 32-bit Instant Client Basic files into it, and added the suggested entries to web.config, but when I try running the app locally, I get two sorts of exceptions thrown.

Here is the web.config file:

<configuration>
  <configSections>
    <section name="oracle.dataaccess.client"
             type="System.Data.Common.DbProviderConfigurationHandler, System.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </configSections>
  <system.data>
    <DbProviderFactories>
      <!-- Remove in case this is already defined in machine.config -->
      <remove invariant="Oracle.DataAccess.Client" />
      <add name="Oracle Data Provider for .NET"
           invariant="Oracle.DataAccess.Client"
           description="Oracle Data Provider for .NET"
           type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
    </DbProviderFactories>
  </system.data>
  <system.web>
    <compilation debug="true" targetFramework="4.6.1" />
    <httpRuntime targetFramework="4.6.1" />
  </system.web>

  <oracle.dataaccess.client>
    <settings>
      <add name="DllPath"               value="C:\ora\InstantClient32_12-2-0-1-0"/>
      <add name="FetchSize"             value="1048576"/>
      <add name="PromotableTransaction" value="promotable"/>
      <add name="StatementCacheSize"    value="10"/>
      <add name="TraceFileName"         value="C:\ora\InstantClient32_12-2-0-1-0\odpnet2.trc"/>
      <add name="TraceLevel"            value="0"/>
      <add name="TraceOption"           value="1"/>
    </settings>
  </oracle.dataaccess.client>

</configuration>

However,

OracleConnection conn = new OracleConnection(connectionString);

(where connectionString is a valid connection string) throws,

The provider is not compatible with the version of Oracle client.

If I change 4.0.0.0 to 4.112.3.0 in the ConfigSection entry, it throws,

Could not load file or assembly 'System.Data, Version=4.112.3.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

Note that oracle.dataaccess.client is a 32-bit client - but I think system.data might be 64-bit (is there any way to tell the difference?).

Also note that, because the app depends on an external app that also uses the 32-bit unmanaged oracle.dataaccess client, I can't switch from OracleClient to OracleManagedClient.

I am running this on the 32-bit IIS Express. I have also tried switching the CPU to "x86", with no effect.

What do I need to do to get this running?

EDIT When I change the DllPath setting to a directory that does not exist, it still throws, "The provider is not compatible with the version of Oracle client." I am guessing that DllPath does not do what I think it does, and Oracle.DataAccess is trying to use my installed full version of Oracle (which is 64-bit).

Next question: how do I get my app to use the 32-bit Instant Client files that I have?

  • Why can't you use the Oracle Managed Client? I don't understand your reasoning. – mason Aug 23 '17 at 14:29
  • The external library that I need to include needs the unmanaged one – Don Del Grande Aug 23 '17 at 14:32
  • You said in your question it was an external app. You said in your comment it was an external library. Which is it? If it's a library, why can't you just use binding redirects? – mason Aug 23 '17 at 14:33
  • Edited my original post - I don't think the problem is with System.Data or Oracle.DataAccess per se, but not finding the version of Oracle Client on my machine – Don Del Grande Aug 23 '17 at 15:09
  • Yes, and by using the Managed client there is no need to have an Oracle Client on your machine, or worry about matching the bitness. You just provide a connection string to the database and you're good to go. – mason Aug 23 '17 at 15:36
  • Then back to my earlier question - how do I get the unmanaged client in the DLL I have to include (and I can't modify) to work? You mentioned a binding redirect, but how can you bind oracle.dataaccess.client to oracle.manageddataaccess.client? – Don Del Grande Aug 23 '17 at 15:58
  • @mason, almost - you also have to provide a copy of `Oracle.ManagedDataAccess.Client` if not installed on target machine. – Wernfried Domscheit Aug 23 '17 at 17:19
  • Follow this instruction to install 32bit and 64bit Oracle client on one machine: https://stackoverflow.com/questions/24104210/badimageformatexception-this-will-occur-when-running-in-64-bit-mode-with-the-32#24120100 - or use the managed driver as proposed. – Wernfried Domscheit Aug 23 '17 at 17:20
  • @WernfriedDomscheit I thought that "install the NuGet package for Oracle Managed Client" was implicit by saying "use the Managed client" – mason Aug 23 '17 at 17:21

1 Answers1

0

Turns out that the problem was, the Instant Client directory didn't have the right version of OraOps11w.dll in it.