The provider is not compatible with the version of

2018-12-31 08:34发布

I'm trying to use the Oracle ODP.NET 11g (11.1.0.6.20) Instant Client on my ASP.net project as a Data Provider but 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.

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

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

26条回答
与君花间醉酒
2楼-- · 2018-12-31 09:39

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

查看更多
时光乱了年华
3楼-- · 2018-12-31 09:39

I didn't go down the road of getting new DLL's. We had a bunch of existing projects that work perfectly fine and it was only my new project that was giving me headache so I decided to try something else.

My project was using an internally developed Internal.dll that depended on Oracle.DataAccess.dll v4.112.3.0. For some reason, when publishing, Visual Studio always uploaded v4.121.0.0, even though it wasn't explicitly specified in any of the config files. That's why I was getting an error.

So what I did was:

  1. Copied Internal.dll from one of the successfully running projects to my web site's /bin (just to be on the safe side).
  2. Copied Oracle.DataAccess.dll from one of the successfully running projects to my web site's /bin.
  3. Add Reference to both of them from my web site.
  4. Finally Oracle.DataAccess reference showed up in myWebSite.csproj, but it showed the wrong version: v4.121.0.0 instead of v4.112.3.0.
  5. I manually changed the reference in myWebSite.csproj, so it now read:

    <Reference Include="Oracle.DataAccess, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342, processorArchitecture=x86">
      <SpecificVersion>False</SpecificVersion>
      <HintPath>bin\Oracle.DataAccess.dll</HintPath>
    </Reference> 
    
查看更多
登录 后发表回答