C# 提供程序与 Oracle 客户端版本不兼容

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/659341/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 12:15:31  来源:igfitidea点击:

The provider is not compatible with the version of Oracle client

c#asp.netoracleodp.netoracleclient

提问by EverTheLearner

I'm trying to use the Oracle ODP.NET 11g (11.1.0.6.20) Instant Clienton my ASP.net project as a Data Providerbut when I run the aspx page I get a "The provider is not compatible with the version of Oracle client" error message. Any help would be appreciated.

我正在尝试在我的 ASP.net 项目上使用Oracle ODP.NET 11g (11.1.0.6.20) Instant Client作为数据提供程序,但是当我运行 aspx 页面时,我得到一个“提供程序与版本不兼容Oracle 客户端”错误消息。任何帮助,将不胜感激。

I've referenced the Data Provider in Visual Studio 2005 and the code behind looks like this:

我在 Visual Studio 2005 中引用了数据提供程序,后面的代码如下所示:

using Oracle.DataAccess.Client;
..

OracleConnection oOracleConn = new OracleConnection();
oOracleConn.ConnectionString =
    "Data Source=MyOracleServerName;" +
    "Integrated Security=SSPI";
oOracleConn.Open();

//Do Something

oOracleConn.Close();

The error for the page looks like this:

该页面的错误如下所示:

Exception Details: Oracle.DataAccess.Client.OracleException: The provider is not compatible with the version of Oracle client

Source Error: 
Line 21: 
Line 22: 
Line 23:             OracleConnection oOracleConn = new OracleConnection();
Line 24:             oOracleConn.ConnectionString =
Line 25:                 "Data Source=MyOracleServerName;" +

[OracleException (0x80004005): The provider is not compatible with the version of Oracle client]
   Oracle.DataAccess.Client.OracleInit.Initialize() +494
   Oracle.DataAccess.Client.OracleConnection..cctor() +483

Stack Trace: 
[TypeInitializationException: The type initializer for 'Oracle.DataAccess.Client.OracleConnection' threw an exception.]
   Oracle.DataAccess.Client.OracleConnection..ctor() +0
   Boeing.IVX.Web.RoyTesting.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\CE218C\Desktop\IVX.Net\Web\IVX\RoyTesting.aspx.cs:23
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +47
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436

采纳答案by EverTheLearner

I only installed the Oracle Data Provider for .NET 2.0 (11.1.0.6.20)and I did not install the Oracle Instant Client (11.1.0.6.0).

我只安装了Oracle Data Provider for .NET 2.0 (11.1.0.6.20)而我没有安装Oracle Instant Client (11.1.0.6.0)

I just installed it and the error disappeared!

我刚刚安装了它,错误消失了!

回答by DCookie

Does the IIS/IWAM user have permissions on the Oracle directory? Can you connect to this data source using another app, such as Excel or Access?

IIS/IWAM 用户是否对 Oracle 目录具有权限?是否可以使用其他应用程序(例如 Excel 或 Access)连接到此数据源?

回答by Peter Meyer

It would seem to me that though you have ODP with the Oracle Istant Client, the ODP may be trying to use the actual Oracle Client instead. Do you have a standard Oracle client installed on the machine as well? I recall Oracle being quite picky about when it came to multiple clients on the same machine.

在我看来,虽然您有 ODP 和 Oracle Instant Client,但 ODP 可能会尝试使用实际的 Oracle Client。您的机器上是否也安装了标准的 Oracle 客户端?我记得 Oracle 对同一台机器上的多个客户端非常挑剔。

回答by Daniel

This can be caused by running a 64bit .NET runtime against a 32bit Oracle client. This can happen if your server you are running the app on it 64 bit. It will run the .NET app with the 64bit runtime. You can set the CPU flag on your project in VS to run in the 32bit runtime.

这可能是由于对 32 位 Oracle 客户端运行 64 位 .NET 运行时造成的。如果您的服务器在 64 位上运行该应用程序,则可能会发生这种情况。它将使用 64 位运行时运行 .NET 应用程序。您可以在 VS 中为您的项目设置 CPU 标志以在 32 位运行时中运行。

回答by Daniel

I had the exact same problem. I deleted (and forgot that I had deleted) oraociei11.dll after compiling the application. And it was giving this error while trying to execute. So when it cant find the dll that oraociei11.dll, it shows this error. There may be other cases when it gives this error, but this seems to be one of them.

我有同样的问题。编译应用程序后,我删除了(忘记我已经删除了)oraociei11.dll。它在尝试执行时给出了这个错误。所以当它找不到oraociei11.dll的dll时,就会显示这个错误。可能还有其他情况会出现此错误,但这似乎是其中之一。

回答by Chris

I've been looking into this problem further, and you simply need to grab all the appropriate DLL's from the same downloaded version of ODP.Net and put them in the same folder as your Exe file, because ODP.Net is fussy about not mixing version numbers.

我一直在进一步研究这个问题,你只需要从 ODP.Net 的相同下载版本中获取所有适当的 DLL 并将它们放在与你的 Exe 文件相同的文件夹中,因为 ODP.Net 对不混合很挑剔版本号。

I've explained how to do this here: http://splinter.com.au/using-the-new-odpnet-to-access-oracle-from-cHere's the gist of it though:

我已经在这里解释了如何做到这一点:http: //splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c这是它的要点:

  • Download ODP.Net
  • Unzip the file
  • Unzip all the JAR's in it
  • Grab these dll's that were just unzipped:
    • oci.dll (renamed from 'oci.dll.dbl')
    • Oracle.DataAccess.dll
    • oraociicus11.dll
    • OraOps11w.dll
    • orannzsbb11.dll
    • oraocci11.dll
    • ociw32.dll (renamed from 'ociw32.dll.dbl')
  • Put all the DLLs in the same folder as your C# Executable
  • 下载 ODP.Net
  • 解压文件
  • 解压其中的所有 JAR
  • 获取这些刚刚解压的 dll:
    • oci.dll(从'oci.dll.dbl'重命名)
    • Oracle.DataAccess.dll
    • oraociicus11.dll
    • OraOps11w.dll
    • orannzsbb11.dll
    • oraocci11.dll
    • ociw32.dll(从'ociw32.dll.dbl'重命名)
  • 将所有 DLL 放在与 C# 可执行文件相同的文件夹中

回答by HainKurt

install ODP.Net on the target machine and it should solve the issue... copying the dll's does not look a good idea...

在目标机器上安装 ODP.Net,它应该可以解决问题......复制 dll 看起来不是一个好主意......

回答by SKG

For Oracle 11g (11.1.0.7.20) I had to add the following dlls along with my Exe to work.

对于 Oracle 11g (11.1.0.7.20),我必须添加以下 dll 和我的 Exe 才能工作。

  1. oci.dll
  2. OraOps11w.dll
  3. oraociicus11.dll (pretty huge close to 30mb)
  4. Oracle.DataAccess.dll
  1. oci.dll
  2. OraOps11w.dll
  3. oraociicus11.dll(相当大,接近 30mb)
  4. Oracle.DataAccess.dll

回答by Hydtechie

Also look for IIS Application pool Enable 32-bit true or false flag, when you see this message, some oracle forum directed me for this!

还要寻找IIS Application pool Enable 32-bit true or false flag,当你看到这个消息时,一些oracle论坛指示我这样做!

回答by doekman

We had the same problem, because the Oracle.Data.dll assembly on a network share was updated by our DBA's. Removing the reference from the project, and adding it again solved the problem.

我们遇到了同样的问题,因为我们的 DBA 更新了网络共享上的 Oracle.Data.dll 程序集。从项目中删除引用,并再次添加它解决了问题。