How to fix "The provider is not compatible with the version of Oracle client"?
Asked Answered
K

3

5

We're using the Oracle.DataAccess.dll assembly version 2.102.2.20 (32 bit).

I deployed our Web API application to IIS and tried openning and closing a connection:

 private static void CheckConnectionUsingOracleClient(string connection)
        {
            var logger = DiContainer.Resolve<ILogger>();

            try
            {
                logger.LogInfo("Trying to connect to " + connection);
                // check whether you can connect to the shop using Oracle.DataAccess
                using (var cnn = new Oracle.DataAccess.Client.OracleConnection(connection))
                {
                    cnn.Open();
                    cnn.Close();
                }

                logger.LogInfo("Succeeded to connect to " + connection);
            }
            catch (System.Exception ex)
            {
                logger.LogError("Failed to connect to " + connection, ex);
            }
        }

On my local machine it's fine, but on this server it throws an exception when trying to initalize the the OracleConnection:

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

I've installed Oracle client 11.2 (32 bit) on the server and I can see that in the GAC (c:\windows\assembly) the Oracle.DataAccess assembly is installed in 32 bit Processor Architecture. It works fine on one of our servers but not this one.

In IIS also, I've set 'Enable 32 bit Application' on the Application Pool.

How can it be fixed? I've spent over 10 hours so far trying different things :(

I'd ideally like to be able to use Oracle.DataAccess.dll without the need to install an Oracle Client on the server.

Kermis answered 2/7, 2013 at 12:22 Comment(2)
Possibly problems with the driver of the connector. Try to remove/install others versions.Faucal
Possible duplicate of #659841Larocca
S
5

Oracle.DataProvider version 2.102.2.20 decrypted

2: .Net version (can be 1 for .Net 1 - 1.1, 2 for 2 - 3.5 and 4 for 4 - 4.5)

102: Oracle version: Oracle 10.2

2.20: Oracle Data access version

You should check

  1. .Net version (should not be higher than your .Net compiler)

  2. Oracle client version (should not exceed Oracle Client version)

  3. Both Oracle client and Oracle.DataProvider are 64-bit or Oracle.DataProvider is 32 bit and Oracle client is either 32 bit or supports legacy 32 bit mode

Skiascope answered 2/7, 2013 at 12:29 Comment(1)
I'm working with .NET 4.5. Oracle Client version 11.2 is installed in another PC and it works fine. They are all 32 bits.Kermis
P
5

you can install Oracle.ManagedDataAccess using Package Manager Console nuget

Pm> Install-Package Oracle.ManagedDataAccess

ODP.NET, Managed Driver is a 100% native .NET code driver. No additional Oracle Client software is required to be installed to connect to Oracle Database.

Update Code

using Oracle.ManagedDataAccess.Client;
private static void CheckConnectionUsingOracleClient(string connection)
        {
            var logger = DiContainer.Resolve<ILogger>();

            try
            {
                logger.LogInfo("Trying to connect to " + connection);
                // check whether you can connect to the shop using Oracle.DataAccess
                using (var cnn = new OracleConnection(connection))
                {
                    cnn.Open();
                    cnn.Close();
                }

                logger.LogInfo("Succeeded to connect to " + connection);
            }
            catch (System.Exception ex)
            {
                logger.LogError("Failed to connect to " + connection, ex);
            }
        }
Patriarchy answered 9/10, 2016 at 4:59 Comment(0)
E
2

After installation make sure:

  • PATH is updated with Oracle dlls location: \product\12.1.0\client_1\bin and \product\12.1.0\client_1
  • Restart the server.
  • Enable 32bit for the App Pool in IIS.
Episcopalian answered 19/7, 2014 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.