我是一名初级 .net 开发人员。我开发了一个简单的客户端应用程序 (.net3.5),它需要从 10g oracle 数据库服务器获取结果。此应用程序将部署在 100 个未安装 oracle 但可以访问服务器的 32 位系统中。我们不打算让用户在他们的机器上安装 oracle。那可能吗?我关注了http://www.splinter.com.au/using-the-new-odpnet-to-access-oracle-from-c/在此链接中所说的任何内容,它会生成底部提到的版本不匹配错误的链接。它是否可以在用户机器上没有oracle客户端的情况下工作,因为它在我的机器上运行良好,因为它安装了oracle。有没有其他方法可以解决这个问题?
我的连接字符串是:
OracleConnection conn = new OracleConnection();
conn.ConnectionString = "User ID=<userid>;Password=*******;Data Source=<data source>";
conn.Open();".
产生的异常是:
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** 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()
at WindowsFormsApplication1.frmVoiceFileMover2.cmdGetId_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: 4.0.0.0
Win32 Version: 4.0.30319.269 (RTMGDR.030319-2600)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
VoiceFileMover2
Assembly Version: 1.0.0.0
Win32 Version: 1.0.0.0
CodeBase: file:///C:/Program%20Files/State%20of%20Maine/VFM2Setup/VoiceFileMover2.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.278 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.282 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.269 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
Oracle.DataAccess
Assembly Version: 2.111.6.20
Win32 Version: 2.111.6.20
CodeBase: file:///C:/Program%20Files/State%20of%20Maine/VFM2Setup/Oracle.DataAccess.DLL
----------------------------------------
System.Data
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.237 (RTMGDR.030319-2300)
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Data/v4.0_4.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Transactions
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_32/System.Transactions/v4.0_4.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.Configuration
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.233 built by: RTMGDR
CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
我在开发机器上安装了 2 个 oracle 客户端 10.2 和 11.2。我从 11.2 客户端将 oracle.dataaccess.dll 引用到我的项目,然后当它不起作用时,我下载了最新版本的 odp.net 并再次引用。当我仍然看到此异常时,我尝试使用 odp。 net 也适用于 10g,但我在 10g 中找不到 oracle.dataaccess.dll。这是因为 GAC 的问题吗?
我还尝试根据此链接“http://www.youtube.com/watch?v=I1q50HnUh_w”使用 ODP.net 托管驱动程序测试版。
我是否必须在每台机器上安装 oracle 客户端。我不能在项目中打包所需的 dll 并使其工作吗?如果即时 oracle 静默使其工作,我如何继续使用即时客户端。我目前唯一的希望是找到10g odp.net中是否有文件oracle.dataaccess.dll,使其与服务器中的oracle版本匹配,以使其工作。如果不是,我该如何使用 oracle 即时客户端?非常感谢任何帮助。