代码之家  ›  专栏  ›  技术社区  ›  Sathyajith Bhat ron tornambe

使用Oracle.DataClient时,提供程序与Oracle客户端错误的版本不兼容

  •  16
  • Sathyajith Bhat ron tornambe  · 技术社区  · 17 年前

    我正在使用Visual Studio 2008 Express Edition,我正在尝试使用Oracle.DataClient开发一个小型应用程序。 我在尝试连接到目标系统中的数据库时遇到上述错误。

    在发布这篇文章之前,我读了 this post 现在,我已经安装了即时客户端,错误仍然存在。 下面是完整的错误堆栈。

    ************** 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
    

    我在开发应用程序的机器上安装了Oracle11g,它在那里运行良好,但在目标机器上,我遇到了这个错误。 如有任何意见,将不胜感激。

    PS:如上所述,引用的Oracle.DataClient.dll文件版本对应于10gR2,而不是11g。

    5 回复  |  直到 9 年前
        1
  •  17
  •   Chris    15 年前

    我一直在进一步研究这个问题,您只需从相同下载版本的ODP.Net中获取所有适当的DLL,并将它们放在与您的Exe文件相同的文件夹中,因为ODP.Net对不混合版本号很挑剔,这就是您看到的问题(或者是oci.dll完全丢失,在这种情况下,它会给出同样的错误)。

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

        2
  •  1
  •   DCookie    17 年前

    您是否已在客户端系统上使用ODBC管理员创建并成功测试了连接?

    9i和10g客户端中存在导致此错误的权限问题的修补程序。如果您的版本是10.2.0.1,则可能需要升级到10.2.0.3才能解决此问题。

        3
  •  0
  •   Sathyajith Bhat ron tornambe    17 年前

    我已经让我的应用程序使用Oledb(System.Data.oledbnamespace)连接,并且运行良好。考虑到该应用程序只是调用Oracle SP的前端,并且没有返回任何值,我想这种方法是可以接受的,因为在我花了2天时间试图找到解决此问题的方法后,我本可以在该应用程序上完成更多的开发。

        4
  •  0
  •   andrewWinn    17 年前

    我遇到了同样的问题。如果您的计算机上安装了11g客户端,则需要使用11g ODP.Net DLL。我必须完全卸载所有东西,然后安装11g客户端,然后安装11g ODP.NET驱动程序。驱动程序安装在GAC中,这会有点痛苦。

    我们也必须在服务器上这样做。

        5
  •  0
  •   Jaswanth    8 年前

    即使安装了适当的Oracle客户端版本,我们也必须检查服务器中安装了哪个.Net Framewark,ODP.Net支持.Net Framework 3.5到4.5.2。