如何获得旧版本的OracleClient以在.NET本地工作? [英] How do I get an older version of OracleClient to work locally with .NET?

查看:81
本文介绍了如何获得旧版本的OracleClient以在.NET本地工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用Oracle.DataAccess.dll创建一个新的.NET应用程序时,它运行良好.但是,我需要编辑安装了旧版本Oracle.DataAccess.dll的现有Web应用程序,当我尝试在本地运行它时,它抛出了我们的老朋友,提供程序与Oracle客户端版本不兼容. 例外.

应用程序上的现有版本为2.112.1.2.我有两个版本可用; 4.112.4.0和2.112.4.0. (我创建的适用于该应用程序的应用程序使用4.112.4.0.)显而易见"的答案是在我的应用程序中使用4.112.4.0版本,但是该应用程序调用了一个我无法更改的DLL,该DLL也使用2.112.1.2. /p>

如何在不更改基础DLL的情况下使应用程序正确连接到Oracle?请注意,我正在使用11gR2和Visual Studio 2013.

解决方案

在您的*.csproj中,分别是. *.vbproj像这样编辑对ODP.NET的引用:

    <Reference Include="Oracle.DataAccess">
      <SpecificVersion>False</SpecificVersion>
      <Private>False</Private>
    </Reference>

不需要像Version=...processorArchitecture=...这样的属性.您的应用程序将根据所选的体系结构和目标.NET Framework(如果已正确安装)加载正确的Oracle.DataAccess.dll

但是,您引用的是OracleClient.dll,它是已弃用的Microsoft数据提供程序( Oracle和ADO .NET ),然后编写4.11.2.4.0和2.112.4.0版本,这是Oracle数据提供程序(ODP.NET,Oracle.DataAccess.dll).在某个地方将其混合.

您选择的目标框架版本是什么?当您设置4.0或4.5或4.5.1时,它将尝试加载Oracle dll版本4.x.为了使用2.x版,您必须设置目标框架2.0、3.0或3.5

When I create a new .NET app with Oracle.DataAccess.dll, it works fine. However, I need to edit an existing web application with an older version of Oracle.DataAccess.dll installed, and when I try to run it locally, it throws our old friend, the "The provider is not compatible with the version of Oracle client" exception.

The existing version on the app is 2.112.1.2. I have two versions available; 4.112.4.0 and 2.112.4.0. (The apps I create that work use 4.112.4.0.) The "obvious" answer would be to use the 4.112.4.0 version in my app, but the app calls a DLL I can't change that also uses 2.112.1.2.

How do I get the app to connect to Oracle correctly without having to change the underlying DLL? Note that I am using 11gR2 and Visual Studio 2013.

解决方案

In your *.csproj, resp. *.vbproj edit your reference to ODP.NET like this:

    <Reference Include="Oracle.DataAccess">
      <SpecificVersion>False</SpecificVersion>
      <Private>False</Private>
    </Reference>

Attributes like Version=... or processorArchitecture=... are not required. Your application will load the correct Oracle.DataAccess.dll depending on selected architecture and target .NET framework (provided that it is installed properly)

However, you refer to OracleClient.dll which is the deprecated Microsoft Data Provider (Oracle and ADO.NET) but then you write version 4.112.4.0 and 2.112.4.0 which is the Oracle Data Provider (ODP.NET, Oracle.DataAccess.dll). Somewhere you mix it up.

What is the target Framework version you selected? When you set 4.0 or 4.5 or 4.5.1 then it will try to load Oracle dll version 4.x. In order to use version 2.x you must set target framework 2.0, 3.0 or 3.5

这篇关于如何获得旧版本的OracleClient以在.NET本地工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆