oracle 适用于 32 位和 64 位的 ODP.NET

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6959988/
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-19 00:13:00  来源:igfitidea点击:

ODP.NET for both 32bit and 64bit

c#.netoracleado.netodp.net

提问by NDeveloper

I am developing application which uses ODP.NET to connect to Oracle DB. I would like to have one version for both 32bit and 64bit machines. The problem is that I couldn't figure out how to build projetc with anycputarget, seems it requires the target to be the same as ODP driver version. So it means that I need to have to versions of the same application one for 32bit and other for 64bit. But the same was not problem while using MS .NET Oracle client (System.Data.OracleClient). Is there a way to have the same behavior using ODP.NET as on MS .NET client?

我正在开发使用 ODP.NET 连接到 Oracle DB 的应用程序。我想为 32 位和 64 位机器提供一个版本。问题是我不知道如何使用anycpu目标构建 projetc ,似乎它要求目标与 ODP 驱动程序版本相同。所以这意味着我需要有相同的应用程序版本,一个用于 32 位,另一个用于 64 位。但是使用 MS .NET Oracle 客户端 (System.Data.OracleClient) 时同样没有问题。有没有办法使用 ODP.NET 与 MS .NET 客户端具有相同的行为?

回答by Buthrakaur

Just update few years later: Oracle released managed ODP.NET client, so there's no need to bother with x64/x86 in .NET applications any more. You can find more information on Oracle website: http://www.oracle.com/technetwork/topics/dotnet/index-085163.html

几年后才更新:Oracle 发布了托管 ODP.NET 客户端,因此无需再为 .NET 应用程序中的 x64/x86 烦恼。您可以在 Oracle 网站上找到更多信息:http: //www.oracle.com/technetwork/topics/dotnet/index-085163.html

回答by Branko Dimitrijevic

The root cause is the ODP.NET's reliance on nativeOCI DLLs, which of course cannot be "Any CPU".

根本原因是 ODP.NET 对本机OCI DLL的依赖,这当然不能是“任何 CPU”。

Theoretically, ODP.NET could detect the "bit-ness" of the current execution in the .NET code and then dynamically load either 32-bit or 64-bit native DLLs accordingly, but that's not how it is currently implemented.

理论上,ODP.NET 可以检测 .NET 代码中当前执行的“位”,然后相应地动态加载 32 位或 64 位本机 DLL,但这不是它当前的实现方式。

Oracle corporation is currently in the process of implementing a fully managed provider. But until then, we are stuck with having to do separate builds for each "bit-ness".

Oracle 公司目前正在实施一个完全托管的提供程序。但在那之前,我们不得不为每个“位”进行单独的构建。

回答by Security Hound

The default option for any C# project is it will work on both x64 and x86 operating systems.

任何 C# 项目的默认选项是它可以在 x64 和 x86 操作系统上运行。

So it means that I need to have to versions of the same application one for 32bit and other for 64bit. But the same was not problem while using MS .NET Oracle client (System.Data.OracleClient).

所以这意味着我需要有相同的应用程序版本,一个用于 32 位,另一个用于 64 位。但是使用 MS .NET Oracle 客户端 (System.Data.OracleClient) 时同样没有问题。

This is expected....You need to release a x86 version and a x64 version, please take note, x86 application cannot reference a x64 assembly and vice-versa.

这是预期的....您需要发布一个 x86 版本和一个 x64 版本,请注意,x86 应用程序不能引用 x64 程序集,反之亦然。

The reason the Microsoft reference was different was because its part of the .NET Framework by default.

Microsoft 引用不同的原因是默认情况下它是 .NET Framework 的一部分。

I cannot download the file where I am at, I do believe that, ODP.NET has a x86 assembly and a x64 assembly.

我无法下载我所在的文件,我相信 ODP.NET 有一个 x86 程序集和一个 x64 程序集。

The correct way is to release a x86 version and a x64 version of your program.

正确的方法是发布一个 x86 版本和一个 x64 版本的程序。

回答by user3923143

ODP.NET is specifically built for either 32-bit or 64-bit platform. They could have built a single library for AnyCPU which would allow it to be used in a 32-bit or 64-bit process. However, as Branko Dimitrijevic alluded to, the ODP.NET managed dll uses native libraries behind the scenes. Native libraries are platform-specific; thus requiring Oracle to build separate ODP.NET library for each platform. There is no alternative.

ODP.NET 专为 32 位或 64 位平台构建。他们本可以为 AnyCPU 构建一个单独的库,这将允许它在 32 位或 64 位进程中使用。然而,正如 Branko Dimitrijevic 所暗示的,ODP.NET 托管的 dll 在幕后使用了本机库。本机库是特定于平台的;因此要求 Oracle 为每个平台构建单独的 ODP.NET 库。没有替代。