问题描述
我正在使用Visual Studio 2008 Express Edition,并且正在尝试使用Oracle.DataClient开发一个小型应用程序.尝试连接到目标系统中的数据库时出现上述错误.
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.
我添加了对Oracle 10gR2的Oracle ODP.net提供程序的引用,并且在目标计算机中,我安装了Oracle 10gR2数据库的副本.尽管如此,我得到了错误.在发布此内容之前,我阅读了这篇文章在SO,并且我已经安装了即时客户端,该错误仍然存在.下面是完整的错误堆栈.
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 post at SO, and I have installed the instant client, the error persists.Below is the full error stack.
************** 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
我在开发该应用程序的计算机上安装了Oracle 11g,并且在该计算机上运行正常,但是在目标计算机上,出现此错误.任何输入将不胜感激.
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.
PS:如上所述,所引用的Oracle.DataClient.dll文件版本对应于10gR2,而不是11g.
PS: As mentioned above, the referenced Oracle.DataClient.dll file version corresponds to 10gR2, not 11g.
推荐答案
我一直在研究这个问题,您只需要从相同的ODP.Net下载版本中获取所有适当的DLL并将它们放入与您的Exe文件位于同一文件夹,因为ODP.Net对于不混用版本号非常挑剔,这就是您所看到的问题(要么完全丢失oci.dll,在这种情况下,它就会令人讨厌地给出相同的错误)
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).
我已经在此处说明了如何执行此操作: http://splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c 这是它的要旨:
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://www.oracle.com/technology /software/tech/windows/odpnet/index1110710beta.html
- 解压缩文件
- 解压缩其中的所有JAR文件
- 获取刚刚解压缩的这些dll:oci.dll(从"oci.dll.dbl"重命名)Oracle.DataAccess.dlloraociicus11.dllOraOps11w.dllorannzsbb11.dlloraocci11.dllociw32.dll(从"ociw32.dll.dbl"重命名)
- 将所有DLL与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.dlloraociicus11.dllOraOps11w.dllorannzsbb11.dlloraocci11.dllociw32.dll (renamed from 'ociw32.dll.dbl')
- Put all the DLLs in the same folder as your C# Executable
这篇关于使用Oracle.DataClient时提供程序与Oracle客户端错误的版本不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!