如何修复“提供程序与Oracle客户端版本不兼容"? [英] How to fix "The provider is not compatible with the version of Oracle client"?

查看:375
本文介绍了如何修复“提供程序与Oracle客户端版本不兼容"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用Oracle.DataAccess.dll程序集版本2.102.2.20(32位).

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

我将Web API应用程序部署到IIS,并尝试打开和关闭连接:

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);
            }
        }

在我的本地计算机上还可以,但是在此服务器上尝试初始化OracleConnection时会引发异常:

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

'Oracle.DataAccess.Client.OracleConnection'的类型初始值设定项 引发了异常. ---> Oracle.DataAccess.Client.OracleException: 提供程序与Oracle客户端版本不兼容

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

我已经在服务器上安装了Oracle客户端11.2(32位),并且可以看到在GAC(c:\ windows \ assembly)中,Oracle.DataAccess程序集已安装在32位处理器体系结构中.它可以在我们的一台服务器上正常运行,但不能在这台服务器上运行.

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.

同样在IIS中,我在应用程序池中设置了启用32位应用程序".

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 :(

理想情况下,我希望能够使用Oracle.DataAccess.dll,而无需在服务器上安装Oracle客户端.

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

推荐答案

您可以安装Oracle.ManagedDataAccess 使用软件包管理器控制台 nuget

you can install Oracle.ManagedDataAccess using Package Manager Console nuget

Pm> Install-Package Oracle.ManagedDataAccess

ODP.NET,托管驱动程序是100%本机.NET代码驱动程序.无需安装其他Oracle Client软件即可连接到Oracle数据库.

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.

更新代码

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);
            }
        }

这篇关于如何修复“提供程序与Oracle客户端版本不兼容"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆