oracle 使用Oracle.DataClient时provider与Oracle客户端版本不兼容报错
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1250644/
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
The provider is not compatible with the version of Oracle client error when using Oracle.DataClient
提问by Sathyajith Bhat
I'm using Visual Studio 2008 Express Edition, and I'm trying my hand in developing a small application using Oracle.DataClient. I'm getting the above mentioned error, when trying to connect to the database in the target system.
我正在使用 Visual Studio 2008 Express Edition,并且正在尝试使用 Oracle.DataClient 开发一个小型应用程序。尝试连接到目标系统中的数据库时,出现上述错误。
I've added a reference to Oracle ODP.net provider for Oracle 10gR2, and in the target machine I have a copy of Oracle 10gR2 database installed. Despite this, I'm getting the error. Before posting this, I read this postat SO, and I have installed the instant client, the error persists. Below is the full error stack.
我为 Oracle 10gR2 添加了对 Oracle ODP.net provider 的引用,并且在目标机器中我安装了 Oracle 10gR2 数据库的副本。尽管如此,我还是收到了错误消息。在发布之前,我在 SO 上阅读了这篇文章,并且我已经安装了即时客户端,但错误仍然存在。以下是完整的错误堆栈。
************** Exception Text **************
System.TypeInitializationException: 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 at Oracle.DataAccess.Client.OracleInit.Initialize()
at Oracle.DataAccess.Client.OracleConnection..cctor()
--- End of inner exception stack trace ---
at Oracle.DataAccess.Client.OracleConnection..ctor(String connectionString)
at Employees1.frmLogin.oralogin()
at Employees1.frmLogin.btnTest_Click(Object sender, EventArgs e)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
API Data Conversion Assistant
Assembly Version: 0.0.0.1
Win32 Version: 0.0.0.1
CodeBase: file:///C:/Documents%20and%20Settings/3i/My%20Documents/My%20Dropbox/Sathya's%20dropbox/VisualStudio%20Releases/APIDataconversion/Application%20Files/API%20Data%20Conversion%20Assistant_0_0_0_3/API%20Data%20Conversion%20Assistant.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
Assembly Version: 2.0.0.0
Win32 Version: 2.0.50727.42 (RTM.050727-4200)
CodeBase: file:///C:/WINDOWS/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Oracle.DataAccess
Assembly Version: 2.102.2.20
Win32 Version: 2.102.2.20
I have Oracle 11g installed on the machine on which I developed the application, and it works fine there, but on the target machine, I'm getting this error. Any inputs will be appreciated.
我在开发应用程序的机器上安装了 Oracle 11g,在那里运行良好,但在目标机器上,我收到此错误。任何输入将不胜感激。
PS: As mentioned above, the referenced Oracle.DataClient.dll file version corresponds to 10gR2, not 11g.
PS:如上所说,引用的Oracle.DataClient.dll文件版本对应的是10gR2,而不是11g。
回答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, which is the problem you're seeing (either that or the oci.dll is totally missing, in which case it annoyingly gives the same error).
我一直在进一步研究这个问题,你只需要从 ODP.Net 的相同下载版本中获取所有适当的 DLL 并将它们放在与你的 Exe 文件相同的文件夹中,因为 ODP.Net 对不混合很挑剔版本号,这是您看到的问题(要么是那个,要么是 oci.dll 完全丢失,在这种情况下,它会令人讨厌地给出相同的错误)。
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 http://www.oracle.com/technology/software/tech/windows/odpnet/index1110710beta.html
- 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
- 下载http://www.oracle.com/technology/software/tech/windows/odpnet/index1110710beta.html
- 解压文件
- 解压缩其中的所有 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 DCookie
Have you created and successfully tested a connection using the ODBC Administrator on your client system?
您是否使用客户端系统上的 ODBC 管理器创建并成功测试了连接?
There is a patch out for a permissions issue in the 9i and 10g client that results in this error. If you're at 10.2.0.1, you may need to upgrade to 10.2.0.3 to solve this.
有针对 9i 和 10g 客户端中导致此错误的权限问题的补丁。如果您使用的是 10.2.0.1,则可能需要升级到 10.2.0.3 才能解决此问题。
回答by Sathyajith Bhat
Well I've made my app use Ole DB(System.Data.Oledb namespace ) connection, and it works fine. Considering that the app is just a front end for calling Oracle SP, and there are no values being returned, I guess this approach is approach acceptable, because in the 2 days I spent trying to figure solution to this problem I could've completed lot more development on the app. I'm still open to answers, as I can learn from what mistake I'm committing for any such applications in the future.
好吧,我让我的应用程序使用 Ole DB(System.Data.Oledb namespace ) 连接,并且它工作正常。考虑到该应用程序只是调用 Oracle SP 的前端,并且没有返回任何值,我想这种方法是可以接受的,因为在我试图找出解决此问题的 2 天内,我本可以完成很多应用程序的更多开发。我仍然愿意接受答案,因为我可以从我将来为任何此类应用程序犯的错误中学习。
回答by andrewWinn
I ran into the same problem. If you have the 11g client installed on your machine, then you need to be using the 11g ODP.Net DLL. I had to completely uninstall everything, and then install the 11g client, and then the 11g ODP.NET drivers. The drivers get installed in the GAC and it gets to be kinda a pain.
我遇到了同样的问题。如果您的机器上安装了 11g 客户端,那么您需要使用 11g ODP.Net DLL。我必须完全卸载所有东西,然后安装 11g 客户端,然后是 11g ODP.NET 驱动程序。驱动程序安装在 GAC 中,这有点痛苦。
*Note, it is my understanding from my DBA that this only works if you don't have to connect to any version less than 9i *
*注意,据我的 DBA 了解,这仅在您不必连接到任何低于 9i 的版本时才有效*
We had to do this on our servers also.
我们也必须在我们的服务器上这样做。
HTH
HTH
回答by Jaswanth
Even after installing the appropriate Oracle Client version, we have to check that which .Net Framewark is installed in the server, ODP.Net supports to .Net Framework 3.5 to 4.5.2.
即使安装了相应的 Oracle Client 版本,我们也必须检查服务器中安装了哪个 .Net Framewark,ODP.Net 支持 .Net Framework 3.5 到 4.5.2。