如何确定要包含哪个版本的“Oracle.DataAccess.dll”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21269520/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 05:27:51  来源:igfitidea点击:

How to determine which version of "Oracle.DataAccess.dll" to include

winformsoraclec#-3.0odp.net

提问by Nil Pun

While deploying my .NET 3.5 Windows form to different environments we ran with lots of invalid provider issues.

在将我的 .NET 3.5 Windows 表单部署到不同环境时,我们遇到了许多无效的提供程序问题。

It works on some and doesn't work on others.

它对某些人有效,对其他人无效。

Could someone please help me out, how do I determine which version of "Oralce.DataAccess.dll" to use i.e. 9 or 10 or 11 or 9.1.* or 10.1.* or 11.* or 12 etc.

有人可以帮助我,我如何确定使用哪个版本的“Oralce.DataAccess.dll”,即 9 或 10 或 11 或 9.1.* 或 10.1.* 或 11.* 或 12 等。

  1. Does it depend on server where I'm installing an application? OR

  2. Does it depend on back end oracle database?

  1. 它是否取决于我安装应用程序的服务器?或者

  2. 它是否依赖于后端oracle数据库?

回答by b_levitt

I second the notion of using the 100% managed provider. It eliminates the need to know details I'm about to discuss. The only issue here is I think you might need to upgrade to .net 4.0.

我支持使用100% 托管提​​供程序的概念。它消除了了解我将要讨论的细节的需要。这里唯一的问题是我认为您可能需要升级到 .net 4.0。

TLDR Version:

TLDR 版本:

  • Use the 12c 100% managed provider instead.
  • The short answer is don't mix the provider (Oracle.DataAccess.dll) with a different version of the unmanaged client (at least not backwards).
  • Consider redesigning to include a service layer that eliminates the need to have the Oracle provider on the client in the first place.
  • 请改用 12c 100% 托管提​​供程序。
  • 简短的回答是不要将提供程序 (Oracle.DataAccess.dll) 与不同版本的非托管客户端(至少不会倒退)混合使用。
  • 考虑重新设计以包含一个服务层,从而首先无需在客户端上安装 Oracle 提供程序。

Full version:

完整版本:

First, lets make sure we understand the components of the old unmnaged provider (not the new 12c 100% managed provider). It's made up of two pieces:

首先,让我们确保我们了解旧的未管理提供程序(而不是新的 12c 100% 托管提​​供程序)的组件。它由两部分组成:

  1. the managed .net component - Oracle.DataAccess.dll
  2. the unmanaged (non-.net) client
  1. 托管的 .net 组件 - Oracle.DataAccess.dll
  2. 非托管(非 .net)客户端

Simply speaking, Oracle.DataAccess.dll is nearly just a wrapper, translating .net instructions into ORACLE-NET instructions for the unmanaged client.

简单地说,Oracle.DataAccess.dll 几乎只是一个包装器,为非托管客户端将 .net 指令翻译成 ORACLE-NET 指令。

That said, when you load Oracle.DataAccess there is a order in which it tries to locate the unmanaged client dlls that it needs. From the Oracle Documentation:

也就是说,当您加载 Oracle.DataAccess 时,它会按照一个顺序尝试查找所需的非托管客户端 dll。从Oracle 文档

The Oracle.DataAccess.dll searches for dependent unmanaged DLLs (such as Oracle Client) based on the following order:

1.Directory of the application or executable.

2.DllPath setting specified by application config or web.config.

3.DllPath setting specified by machine.config.

4.DllPath setting specified by the Windows Registry.

HKEY_LOCAL_MACHINE\Software\Oracle\ODP.NET\version\DllPath

5.Directories specified by the Windows PATH environment variable.

Oracle.DataAccess.dll 根据以下顺序搜索相关的非托管 DLL(例如 Oracle Client):

1.应用程序或可执行文件的目录。

2.由应用程序配置或web.config指定的DllPath设置。

3.由machine.config指定的DllPath设置。

4.DllPath 设置由Windows 注册表指定。

HKEY_LOCAL_MACHINE\Software\Oracle\ODP.NET\version\DllPath

5.Windows PATH 环境变量指定的目录。

This comes into play if you have more than one client installed on the machine so this could be part of your issue. If so, the simple thing to do is use the dllPath configuration variable in your config:

如果您在机器上安装了多个客户端,这就会发挥作用,因此这可能是您问题的一部分。如果是这样,最简单的做法是在您的配置中使用 dllPath 配置变量:

<configuration>
  <oracle.dataaccess.client> 
    <add key="DllPath" value="c:\oracle\product.1.0-xcopy-dep\BIN"/>
  </oracle.dataaccess.client>
</configuration>

Now, to answer your question directly - I don't believe Oracle supports mismatching Oracle.DataAccess.dll with it's client (at least not backwards). Your best bet is either to install ODP.net with your app install - the xcopy versionis the smallest and contains the "instant client" Or, you should be thinking about minimum system requirements - ie. The system must have at least version X of odp.net installed. You could then compile against that minimum dll and rely on publisher policy redirection when a target system has a NEWER version of the client.

现在,直接回答您的问题 - 我不相信 Oracle 支持将 Oracle.DataAccess.dll 与其客户端不匹配(至少不向后)。您最好的选择是在您的应用程序安装中安装 ODP.net - xcopy 版本是最小的并且包含“即时客户端”,或者,您应该考虑最低系统要求 - 即。系统必须至少安装了 odp.net 的 X 版本。然后,您可以针对该最小 dll 进行编译,并在目标系统具有较新版本的客户端时依赖发布者策略重定向。

Of course this also prompts me to ask about architecture. Do you plan on prompting the user for their Oracle account? If not, you have to be careful on how you protect the shared service account your application will use. You may be better off making calls to a webservice that makes the oracle calls on the clients behalf - giving you another security layer and simplifying your client deployment.

当然,这也促使我询问架构。您是否打算提示用户输入他们的 Oracle 帐户?如果没有,您必须小心保护您的应用程序将使用的共享服务帐户。您最好调用代表客户端进行 oracle 调用的 Web 服务 - 为您提供另一个安全层并简化您的客户端部署。

Most version of ODP.net are backwards compatible with the database server - you can certainly use the 11g provider with a 10g database.

大多数版本的 ODP.net 都向后兼容数据库服务器 - 您当然可以将 11g 提供程序与 10g 数据库一起使用。

回答by Wernfried Domscheit

First of all clarification: You have an Oracle Database Server(you called it "back end oracle database") and an Oracle Client(no matter if this is installed on an application server, from Oracle point of view, it is the client)

首先澄清一下:你有一个 Oracle 数据库服务器(你称之为“后端 oracle 数据库”)和一个 Oracle客户端(不管它是否安装在应用服务器上,从 Oracle 的角度来看,它是客户端)

The version of ODP.NET (Oracle Data Provider for .NET, i.e. the Oracle.DataAccess.dll and some more files) are defined by the Oracle Client. You can use almost every ODP.NET version to connect to every Oracle database version - more or less.

ODP.NET 的版本(Oracle Data Provider for .NET,即 Oracle.DataAccess.dll 和一些其他文件)由 Oracle Client 定义。您几乎可以使用每个 ODP.NET 版本连接到每个 Oracle 数据库版本 - 或多或少。

The error message "The provider is not compatible with the version of Oracle client" could also mean there is no ODP.NET provider installed at all. In this case the error message is indeed a bit misleading. So, first check if ODP.NET is installed at all, it is not included in standard Oracle Instant Client installation.

错误消息“提供程序与 Oracle 客户端版本不兼容”也可能意味着根本没有安装 ODP.NET 提供程序。在这种情况下,错误消息确实有点误导。因此,首先检查是否安装了 ODP.NET,它不包含在标准的 Oracle Instant Client 安装中。

When I check all available downloads from Oracle you have ODP.NET version

当我从 Oracle 检查所有可用的下载时,您有 ODP.NET 版本

  • 9.something
  • 10.something
  • 1.x
  • 2.0
  • 4.0
  • 9.东西
  • 10.东西
  • 1.x
  • 2.0
  • 4.0

9.? and 10.? refers to version of Oracle, 1.x, 2.0 and 4.0 refers to version of Microsoft .NET Framwork (strange numbering, but that's how it is). Version 9.? and 10.? are very old, I don't think it makes any sense to use them. 1.x was supported until Oracle client version 11.1.

9.? 和 10.?指的是 Oracle 的版本,1.x、2.0 和 4.0 是指 Microsoft .NET Framwork 的版本(奇怪的编号,但就是这样)。版本 9.? 和 10.?很旧,我认为使用它们没有任何意义。在 Oracle 客户端版本 11.1 之前支持 1.x。

  • If your Oracle client is 11.2 or higher you are forced to include ODP.NET version 2.0 or 4.0.
  • If your Oracle client is between 10.2 and 11.1 you can use eiter ODP.NET version 1.x or 2.0
  • If your Oracle client is older than 10.2, I don't know how it works - it's outdated anyway.
  • 如果您的 Oracle 客户端是 11.2 或更高版本,则您必须包含 ODP.NET 2.0 或 4.0 版。
  • 如果您的 Oracle 客户端在 10.2 和 11.1 之间,您可以使用 ODP.NET 版本 1.x 或 2.0
  • 如果您的 Oracle 客户端早于 10.2,我不知道它是如何工作的 - 无论如何它已经过时了。

Version 1.x and 2.0 are not compatible to each other, i.e. perhpaps you have to provide two different setup files of your application to your customer and the customer has to select the correct one depending on his local oracle client installation.

版本 1.x 和 2.0 彼此不兼容,也就是说,您必须向客户提供两个不同的应用程序安装文件,而客户必须根据其本地 oracle 客户端安装选择正确的一个。

I don't know the situation for 2.0 vs. 4.0, I never used 4.0 so far.

我不知道 2.0 与 4.0 的情况,到目前为止我从未使用过 4.0。

It is not required to put a local copy of Oralce.DataAccess.dll into your application directory. It will be taken from GAC (Global Assembly Cache) where it is installed.

不需要将 Oralce.DataAccess.dll 的本地副本放入您的应用程序目录中。它将从安装它的 GAC(全局程序集缓存)中获取。

In your developing you only have to take care only these mayor version, for example 2.0. Then your loal GAC knows due to policy files which exact version is loaded, e.g. 2.0.10.2.0.2.20 or 2.0.11.1.0.6.20 or 2.0.11.1.0.7.20 or 2.0.11.2.0.1.2 or whatever.

在您的开发中,您只需要注意这些市长版本,例如 2.0。然后,您的本地 GAC 会根据策略文件知道加载了哪个确切版本,例如 2.0.10.2.0.2.20 或 2.0.11.1.0.6.20 或 2.0.11.1.0.7.20 或 2.0.11.2.0.1.2 或其他。

On top of this all you have to know whether your Oracle client is 32bit or 64bit and include ODP.NET accordingly.

最重要的是,您必须知道您的 Oracle 客户端是 32 位还是 64 位,并相应地包含 ODP.NET。

Here you can get more information: Oracle Data Provider for .NET FAQ

您可以在此处获取更多信息:Oracle Data Provider for .NET FAQ

回答by Mohammad shahnawaz

if you have client or oracle instance installed in your system. check the folder name

如果您的系统中安装了客户端或 oracle 实例。检查文件夹名称

ORACLE_HOME\product\11.2.0\dbhome_1\ODP.NET\bin\2.x

ORACLE_HOME\product\11.2.0\dbhome_1\ODP.NET\bin\2.x

here you will find the file - Oracle.DataAccess.dll

在这里你会找到文件 - Oracle.DataAccess.dll

just include in your reference.

只需包含在您的参考中。

回答by SabineA

Sometimes you get the Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies.whereas you have the right dll and the problem is somewhere else.

有时您会得到Could not load file or assembly 'Oracle.DataAccess' or one of its dependencies.正确的 dll,而问题出在其他地方。

It happen to me (and this topic helped me a lot to figure it out) and it was the configuration of my application pool in IIS who wouldn't allow 32 bit applications (advanced settings).

它发生在我身上(这个主题帮助我解决了很多问题)并且我在 IIS 中的应用程序池配置不允许 32 位应用程序(高级设置)。

回答by Aaron

If your Oracle server is version 10.2 or higher, you could consider simply using the managed ODP.NET version which came available with Oracle 12.

如果您的 Oracle 服务器是 10.2 或更高版本,您可以考虑简单地使用 Oracle 12 附带的托管 ODP.NET 版本。

Apparently it's one dependency, under 10 MB. It should make deploying your application to different systems a lot easier compared to the ODP.NET versions that depends on Oracle (instant) Client. It should also avoid you having to care about any installed Oracle Client.

显然这是一个依赖项,不到 10 MB。与依赖 Oracle(即时)客户端的 ODP.NET 版本相比,它应该使您的应用程序部署到不同的系统变得更加容易。它还应该避免您必须关心任何已安装的 Oracle 客户端。

However, they do mention it works on "the latest version of the .NET Framework 4.5.1", so from what I understand you need to upgrade your application to 4.5.1, but maybe that is only if you want to use the certain features (like the Entity Framework support).

但是,他们确实提到它适用于“最新版本的 .NET Framework 4.5.1”,因此据我所知,您需要将应用程序升级到 4.5.1,但也许只有当您想使用某些功能(如实体框架支持)。

http://www.oracle.com/technetwork/topics/dotnet/index-085163.html

http://www.oracle.com/technetwork/topics/dotnet/index-085163.html

回答by Patrick Hofman

In fact I believe there is no right answer. It all depends on the processor architecture (so bits) the application runs with, the version of OCI client you use, etcetera.

事实上,我相信没有正确的答案。这完全取决于应用程序运行所使用的处理器架构(因此位)、您使用的 OCI 客户端版本等。

I found it most useful to wrap the Oracle interaction in one class, using Reflection to find the available version to use.

我发现将 Oracle 交互包装在一个类中最有用,使用反射来查找可用的版本。

Regarding the version number: the version of the ODP.net assemblies must match those of the OCI client installation. It is a bad idea to mix the 12.* OCI client with the 10.* ODP.net assemblies.

关于版本号:ODP.net 程序集的版本必须与 OCI 客户端安装的版本匹配。将 12.* OCI 客户端与 10.* ODP.net 程序集混合在一起是个坏主意。

Maybe this articleis also useful to you.

也许这篇文章对你也有用。