Oracle.DataAccess.client deployment not working

1

I'm deploying an application that uses an oracle provider with Oracle.DataAccess.dll in a machine that already has a specific version of ODAC 64-bit ODAC 11.2.

But the application I want to deploy uses a more recent version of ODAC 64-bit ODAC 12.2c. And in the root of that project I have the provider dll and its dependencies :

  • Oracle.DataAccess.dll
  • OraOps12.dll
  • oci.dll
  • ociw32.dll
  • Oracle.DataAccess.dll
  • orannzsbb12.dll
  • oraocci12.dll
  • oraociei12.dll

Once I deploy and run the application, I have the following error :

Unable to load DLL 'OraOps12.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

I dont want to update the existing ODAC because it might be used by other applications.

I've checked different links as the following one: Oracle.DataAccess.Client Dependencies or this one : Oracle.Dataaccess is in the GAC. Can I control the version I use? but it didn't work for me.

Also i though about using Managed drivers, but based on this link, it doesn't support bulkcopy.

Is there a solution for this issue ? Or is there something I'm doing wrong ?

EDIT

My App.config file looks like this :

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.data>
        <DbProviderFactories>
            <remove invariant="Oracle.DataAccess.Client"></remove>
            <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.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342"></add>
        </DbProviderFactories>  
    </system.data>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89b483f429c47342" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-6.122.1.0" newVersion="4.122.1.0" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>
c#
oracle
odp.net
odac
asked on Stack Overflow Jul 26, 2018 by cheikh ndiaye • edited Jul 27, 2018 by cheikh ndiaye

1 Answer

0

In general it is possible to install more than one version of ODP.NET (Oracle.DataAccess) provider. However, due to unmanaged dependencies you would have to verify/modify the %PATH% environment variable each time before you launch an application which uses an Oracle driver. I don't think this would be a suitable solution.

I would see three possible solutions.

Solution 1

Remove the version attribute from reference. Then the application will load whatever ODP.NET version is installed on the machine.

In your *.csproj, resp. *.vbproj edit your reference to ODP.NET from

<Reference Include="Oracle.DataAccess, Version=4.122.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86">

to this

<Reference Include="Oracle.DataAccess">
  <SpecificVersion>False</SpecificVersion>
  <Private>False</Private>
</Reference>

I never developed a web-sevice, but I assume in web.config file it would be this:

<configuration>
    <system.data>
        <DbProviderFactories>
            <remove invariant="Oracle.DataAccess.Client"></remove>
            <add name="Oracle Data Provider for .NET" invariant="Oracle.DataAccess.Client" 
                 description="Oracle Data Provider for .NET" 
                 type="Oracle.DataAccess.Client.OracleClientFactory, Oracle.DataAccess"></add>
        </DbProviderFactories>  
    </system.data>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Oracle.DataAccess" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

Solution 2

Install Oracle ODP.NET version 12.2 at target machine. Usually this is no problem unless other applications force a specific version (see How to load specific version of assembly from GAC). Other applications which are using Oracle.DataAccess will be redirected automatically to version 12.2 - provided it is installed properly. When I did the last installation of Oracle 12.2 the ODP.NET was not installed in GAC, however you can configure it manually:

For 64-bit Version:

set Oracle_x64=c:\oracle\product\12.2\Client_x64\odp.net
set OraProvCfg_x64=%Oracle_x64%\bin\4\OraProvCfg.exe

"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\bin\2.x\Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\2.x\Policy.2.102.Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\2.x\Policy.2.111.Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\2.x\Policy.2.112.Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\2.x\Policy.2.121.Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\2.x\Policy.2.122.Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\bin\4\Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\4\Policy.4.112.Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\4\Policy.4.121.Oracle.DataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\PublisherPolicy\4\Policy.4.122.Oracle.DataAccess.dll

For 32-bit Version:

set Oracle_x86=c:\oracle\product\12.2\Client_x86\odp.net
set OraProvCfg_x86=%Oracle_x86%\bin\4\OraProvCfg.exe

"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\bin\2.x\Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\2.x\Policy.2.102.Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\2.x\Policy.2.111.Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\2.x\Policy.2.112.Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\2.x\Policy.2.121.Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\2.x\Policy.2.122.Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\bin\4\Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\4\Policy.4.112.Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\4\Policy.4.121.Oracle.DataAccess.dll
"%OraProvCfg_x86%" /action:gac /providerpath:%Oracle_x86%\PublisherPolicy\4\Policy.4.122.Oracle.DataAccess.dll

For ODP.NET Manged Driver (just for information):

set Oracle_x64=c:\oracle\product\12.2\Client_x64\odp.net
set OraProvCfg_x64=%Oracle_x64%\managed\x64\OraProvCfg.exe

"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\managed\common\Oracle.ManagedDataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\managed\PublisherPolicy\4\Policy.4.121.Oracle.ManagedDataAccess.dll
"%OraProvCfg_x64%" /action:gac /providerpath:%Oracle_x64%\managed\PublisherPolicy\4\Policy.4.122.Oracle.ManagedDataAccess.dll

Solution 3

Go to target machine and grab the Oracle.DataAccess.dll file (just the single DLL) and copy it to your development machine. Make a reference to this DLL. When you run/deploy your application then you will be automatically redirected to version 12.2, provided it is installed properly, see above.

answered on Stack Overflow Jul 27, 2018 by Wernfried Domscheit • edited Aug 6, 2018 by Wernfried Domscheit

User contributions licensed under CC BY-SA 3.0