Oracle 11g Client connecting to both 10g and 11g databases

17,163

Solution 1

There is commonly no problem to connect to an older Oracle database with a newer client driver, e.g. to connect to a 10g or 11g database with a 12g Client. The rest of the answer belongs to technical problems which can occur in your .Net program in the case that an Oracle Client is (maybe) already installed on the computer executing your program.


Update 2014:

In the meanwhile Oracle has released a managed .Net driver for the Oracle database. So instead of installing a local Oracle Client or delivering an Instant Client along with your app, the preferred way should be to deliver just the managed driver without any dependencies to local configurations. Then you have no trouble with installed clients, the GAC, the Oracle database version and so on. You can download the managed driver from the Oracle website.


Previous answer, still needed if you can't use the managed driver:

The problems begin if you don't know if there is an Oracle client installed on your client workstations. If you are talking about GAC I assume, you don't know if an Oracle Client is installed and if so, which version it is.

If you don't want to rely on an installed Oracle Client, you can deliver an Oracle Instant Client with your .Net application. For example you can download ODAC 11.2 Release 4 (11.2.0.3.0) with Oracle Developer Tools for Visual Studio, which gives you an Oracle Client installation for your developer workstation (with Visual Studio support for DataSet development and EntityFramework) as well as all files needed for an instant client.

For an instant client you need the following files (search them in the subfolders of your ODAC installation):

  • oci.dll
  • ociw32.dll
  • Oracle.DataAccess.dll
  • orannzsbb11.dll
  • oraociicus11.dll (if you are using english language, else the corresponding .dll)
  • OraOpd11w.dll
  • tnsnames.ora (if you need it)

In addition the following .dll files are needed from your Windows directory:

  • mfc71.dll
  • msvcr71.dll

Just copy all that files in the working directory of your application (where the .exe file is).

Now how belongs that to the GAC?

If an Oracle Client is installed on the client machine there is also an Oracle.DataAccess.dll in the GAC. Also it is possible, that a policy was installed which states something like: Independant of the Oracle.DataAccess.dll your program is referencing, the Oracle.DataAccess.dll version from your GAC shall always be used. If you install the ODAC I linked above, you find that file under

C:\Windows\Microsoft.NET\assembly\GAC_32\Policy.4.112.Oracle.DataAccess\v4.0_4.112.3.0__89b483f429c47342

The result is that your .Net application always throws an exception if you are trying to load the Oracle.DataAccess.dll (with an error message like "The provider is not compatible..."), if the client machine has another version of Oracle Client 11 installed than the one you are referencing in your application.

To solve that, you can configure your app.conf so that the publisher policy will be ignored and always your version is loaded:

<configuration>
...
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Oracle.DataAccess" publicKeyToken="89B483F429C47342" />
        <publisherPolicy apply="no" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

Solution 2

I have not had any problems doing this with JAVA or .Net. In fact, Oracle says it's perfectly fine:

The release incorporates Oracle Database client 11.2.0.3, which can access Oracle Database 9.2 and higher. Oracle supports Entity Framework and LINQ with Microsoft Visual Studio 2010 and .NET Framework 4, including Entity Framework 4.1 and 4.2. Code First is not supported in this release.

Obviously you would want to test the same processes while connect to each one and verify through your own tests, but I think you will be fine.

Share:
17,163
Patrice Cote
Author by

Patrice Cote

Updated on June 20, 2022

Comments

  • Patrice Cote
    Patrice Cote almost 2 years

    I've seen a few post that says Oracle 11g Client (for Windows) works fine with databases up to 9.2. But if the client sometimes connect to 11g and sometimes to 10g databases, is it still working ? My question is : Is there anything to configure differently when connecting to 10g and 11g databases ?

    Some people have told me about policies in the GAC.

    Thanks !

  • Patrice Cote
    Patrice Cote about 12 years
    We are a governement agency, therefore we control what is installed on machines. This will all be the same client version, everywhere. But I take note of your reply, so if we see bizarre error, I'll know where to start looking. Thanks !
  • Desty
    Desty about 12 years
    @ultraman69 In this case you will sleep easy at night :) Since you always use the same client on all machines, no GAC or policy problems will stand in your way. As long as you use the standard interfaces of Oracle.DataAccess.dll, you can connect against any DB version >9.2. Of course, 11g specific functions/SQL will not work on lower versions.
  • Laggel
    Laggel almost 10 years
    @Detsy I have and webservice and I can't set it to 32 bit. Can I use the 64 bit instant client version of the ODC with this same steps?
  • Desty
    Desty almost 10 years
    @Laggel Although I have no experience with using the 64bit driver, you can download one from the Oracle website, so I assume principally it should work the same way. However today you can and should use the managed .Net driver from Oracle, which eliminates the need to deliver an instant client. I have updated my answer to reflect that and hope it is helpful for you.
  • Laggel
    Laggel almost 10 years
    @Detsy I would love to be able to use the managed version. But it is only available for the 12c client and when I tried to use it connect to a 10g database I couldn't.