ODP.NET 是否需要安装 Oracle 客户端

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

Does ODP.NET require Oracle Client installation

.netoracleodp.netoracleclient

提问by llasarov

I have to connect Oracle 11g DB from .NET code. For that purpose I installed ODP.NET bur after reading some forum posts I recognized that I need Oracle Client installation too.

我必须从 .NET 代码连接 Oracle 11g DB。为此,我在阅读了一些论坛帖子后安装了 ODP.NET bur,我意识到我也需要安装 Oracle Client。

Is that true? I see that the Oracle Client has a size of ca. 2GB!!! Do I really need to install such a huge client only to be able to connect Oracle DBs?

真的吗?我看到 Oracle Client 的大小为 ca。2GB!!!我真的需要安装这么大的客户端才能连接 Oracle DB 吗?

回答by Kiquenet

Alex Keh from Oracle in aug 2013 says:

2013 年 8 月来自甲骨文的 Alex Keh 说:

Managed ODP.NET is released. It is currently part of the Oracle DB 12c client. To use managed ODP.NET, you have to download and install the DB client. From there, you can extract just the managed ODP.NET assembly and setup files. These files are less than 10 MB and can be deployed to any target machines.

Currently, we are packaging a stand alone managed ODP.NET release and ODAC 12 release that will be much smaller. This will be released on OTN shortly.

If you can wait a couple of days, ODAC 12c will be out on OTN and you can download that version. That will be our latest and greatest managed ODP.NET version

托管 ODP.NET 发布。它目前是 Oracle DB 12c 客户端的一部分。要使用托管 ODP.NET,您必须下载并安装 DB 客户端。从那里,您可以只提取托管的 ODP.NET 程序集和安装文件。这些文件小于 10 MB,可以部署到任何目标机器。

目前,我们正在打包一个独立托管的 ODP.NET 版本和 ODAC 12 版本,它们会小得多。这将很快在 OTN 上发布。

如果您可以等待几天,ODAC 12c 将在 OTN 上发布,您可以下载该版本。这将是我们最新和最好的托管 ODP.NET 版本

====

====

We do not plan to put managed ODP.NET on NuGet. We believe that the managed ODP.NET download with ODAC will provide the same benefits of NuGet in terms of assembly isolation and download size.

There's a thread discussing whether Oracle should provide managed ODP.NET NuGet support. Once you use ODAC 12c, I would like to know your thoughts on whether NuGet support is still necessary. https://forums.oracle.com/thread/2559445

我们不打算将托管 ODP.NET 放在 NuGet 上。我们相信使用 ODAC 的托管 ODP.NET 下载将在程序集隔离和下载大小方面提供与 NuGet 相同的好处。

有一个讨论 Oracle 是否应该提供托管 ODP.NET NuGet 支持的线程。在您使用 ODAC 12c 后,我想知道您对 NuGet 支持是否仍然有必要的看法。 https://forums.oracle.com/thread/2559445

Nuget managed ODP.NET:

Nuget 管理的 ODP.NET

PM> Install-Package Oracle.ManagedDataAccess

So what is the problem anyway?
Basically up until now, ODP.NET was a .NET layer that talks to the Oracle client .dll files, a small fact that had many implications:

那么到底有什么问题呢?
到目前为止,ODP.NET 基本上是一个与 Oracle 客户端 .dll 文件通信的 .NET 层,这是一个有很多含义的小事实:

  • Large installation footprint (several hundreds of Mb)
  • Tough deployment to remote machines - needs to install ODP.NET on client machine or deploy large files
  • Challenging when working with several versions, 32bit/64bit os and applications
  • 安装空间大(数百 Mb)
  • 难以部署到远程机器 - 需要在客户端机器上安装 ODP.NET 或部署大文件
  • 使用多个版本、32 位/64 位操作系统和应用程序时具有挑战性

So what is it?

那是什么?

The managed driver is basically a single .dll file with a .Net native implementation of ODP.NET.
That means no Oracle Client is needed, and now native code is behind the scenes. XCopy installation can be done easily.

托管驱动程序基本上是单个 .dll 文件,带有 ODP.NET 的 .Net 本机实现。
这意味着不需要 Oracle 客户端,现在本地代码在幕后。XCopy 安装可以轻松完成。

Major benefits:

主要好处:

  • Small footprint
  • Compiled as any cpu so it can work on 32bit/64bit OS and application smoothly. Easy to manage multiple versions on the same machine
  • Can be deployed as a simple reference in the application bin directory.
  • 占地面积小
  • 编译为任何 cpu,因此它可以在 32 位/64 位操作系统和应用程序上顺利运行。易于在同一台机器上管理多个版本
  • 可以部署在应用程序bin目录中作为简单的参考。

So what's the catch?

那么问题是什么?

  • Not all features are supported (although most of them are... ) you can find out more on the documentation
  • Namespace is changed from Oracle.DataAccess.Client to Oracle.ManagedDataAccess.Client
  • Performance differences are still not clear. (The old) Native code always perform very efficiently, but on the other hand 100% managed code has it's performance benefits.
  • 并非所有功能都受支持(尽管其中大多数是...)您可以在文档中找到更多信息
  • 命名空间从 Oracle.DataAccess.Client 更改为 Oracle.ManagedDataAccess.Client
  • 性能差异仍不清楚。(旧的)本机代码总是非常有效地执行,但另一方面,100% 托管代码有它的性能优势。

Please note that the Native-Code ODP.NET is still very much available. The managed version (at least for now) comes in addition to the native one.

请注意,本机代码 ODP.NET 仍然非常可用。托管版本(至少现在)是本机版本的补充。

References: http://oracleatdotnet.blogspot.com.es/2013/07/odpnet-managed-driver-beta-2.html

参考资料:http: //oracleatdotnet.blogspot.com.es/2013/07/odpnet-managed-driver-beta-2.html

Differences between the ODP.NET Managed Driver and Unmanaged Driverhttp://docs.oracle.com/html/E41125_02/intro004.htm

ODP.NET 托管驱动程序和非托管驱动程序之间的差异http://docs.oracle.com/html/E41125_02/intro004.htm

Features of Oracle Data Provider for .NEThttp://docs.oracle.com/database/121/ODPNT/features.htm#ODPNT0007

适用于 .NET 的 Oracle 数据提供程序的特性http://docs.oracle.com/database/121/ODPNT/features.htm#ODPNT0007

回答by Riju

you can get managed ODP.NET using NuGet too https://www.nuget.org/packages/odp.net.managed/

你也可以使用 NuGet 来管理 ODP.NET https://www.nuget.org/packages/odp.net.managed/

PM> Install-Package odp.net.managed 

Watch the quick start video on using ODP.NET Managed Driver! (copied from http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html)

观看有关使用 ODP.NET 托管驱动程序的快速入门视频!(复制自http://www.oracle.com/technetwork/topics/dotnet/whatsnew/index.html

http://www.youtube.com/watch?feature=player_embedded&v=I1q50HnUh_w

http://www.youtube.com/watch?feature=player_embedded&v=I1q50HnUh_w



Update:

更新:

NuGet for Official Oracle ODP.NET, Managed Driver https://www.nuget.org/packages/Oracle.ManagedDataAccess/

NuGet 官方 Oracle ODP.NET,托管驱动程序 https://www.nuget.org/packages/Oracle.ManagedDataAccess/

Or Package Manager Console

或包管理器控制台

PM> Install-Package Oracle.ManagedDataAccess

回答by Branko Dimitrijevic

The ODP.NET does require native OCI DLLs (~130 MB).

ODP.NET 确实需要本机 OCI DLL (~130 MB)。

Probably the easiest way to get all the necessary files is to download the "Oracle Data Access Components with XCopy deployment" from oracle.com.

获取所有必要文件的最简单方法可能是从 oracle.com 下载“具有 XCopy 部署的 Oracle 数据访问组件”。

For your reference, the following DLLs are used by ODP.NET at run-time:

供您参考,ODP.NET 在运行时使用以下 DLL:

oci.dll
Oracle.DataAccess.dll (the managed ODP.NET assembly itself)
orannzsbb11.dll
oraociei11.dll
OraOps11w.dll

BTW, you'll need to be careful whether you are using 32-bit or 64-bit native Oracle DLLs - you must match them with the "bitness" of your managed code. This is especially tricky if you are building for "Any CPU" so the bitness is not fixed.

顺便说一句,无论您使用 32 位还是 64 位本机 Oracle DLL,您都需要小心 - 您必须将它们与托管代码的“位数”相匹配。如果您正在为“任何 CPU”进行构建,则这尤其棘手,因此位数不固定。

回答by vc 74

The latest ODAC releases ship with Oracle instant client so you don't need to install the full client.

最新的 ODAC 版本随 Oracle 即时客户端一起提供,因此您无需安装完整的客户端。

(32 bit release)

32 位版本

(64 bit release)

64 位版本

回答by sampathsris

I am leaving this answer because with the release ODP.net managed driver, old answers are a bit obsolete now.

我离开这个答案是因为随着 ODP.net 托管驱动程序的发布,旧的答案现在有点过时了。

ODP.net managed driver is released now.

ODP.net 托管驱动程序现已发布。

Currently available version ODAC 12cR2 is backwards compatible with Oracle 10gR2 or later. See the System Requirementssection of ODAC 12cR2 Installation Instructions. ODAC 12cR2 requires/supports .Net frameworks from version 4 to 4.5.1.

当前可用的版本 ODAC 12cR2 向后兼容 Oracle 10gR2 或更高版本。请参阅ODAC 12cR2 安装说明系统要求部分。ODAC 12cR2 需要/支持版本 4 到 4.5.1 的 .Net 框架。

Previous version ODAC 12cR1 too is backwards compatible with Oracle 10gR2 or later according to it's installation instructions.

根据其安装说明,先前版本的 ODAC 12cR1 也向后兼容 Oracle 10gR2 或更高版本。

回答by Grastveit

Use the managed oracle-clientwhich is available now. A managaged AnyCPU 6MB dll.

使用现在可用的托管 oracle-client。一个托管的 AnyCPU 6MB dll。

回答by nandox

It worked for me (PC without Oracle Client):

它对我有用(没有 Oracle 客户端的 PC):

Edited:

编辑:

Although this solution worked well; Today, I think the best approach is to use the Oracle Managed Data Access drivers. Is it better when we need to avoid issues between desktop and server environments when one of them is not using the same (32-bit or 64-bits) architecture;

虽然这个解决方案运作良好;今天,我认为最好的方法是使用 Oracle Managed Data Access 驱动程序。当我们需要避免桌面和服务器环境之间的问题之一不使用相同的(32 位或 64 位)架构时,是否更好?

Thanks to Iron Automation:

感谢 Iron Automation:

Link: http://www.iron-automation.com/2018/02/connecting-to-oracle-database-without-installing-oracle-client/

链接:http: //www.iron-automation.com/2018/02/connecting-to-oracle-database-without-installing-oracle-client/

The solution below will apply both to 11g and 12c databases.

下面的解决方案将同时适用于 11g 和 12c 数据库。

Follow the steps:

按照步骤:

  • Step 1

    We will need a set of dlls provided by Oracle to use in our project. So at this first step, download Oracle Data Access Components (ODAC) for your version of Windows. As of the posting date of this article, the valid download URL is: http://www.oracle.com/technetwork/topics/dotnet/downloads/odacdeploy-4242173.html

    Note: ODAC 32 bit version works both for 32bit and 64bit. And I had several problems when using 64bit version. So I can suggests directly downloading the 32bit version.

    Open the downloaded zip file and get the dlls below together. I listed the dlls with the folder where you will find them. We will later copy them into our debug folder.

  • 第1步

    我们将需要一组由 Oracle 提供的 dll 以在我们的项目中使用。因此,在第一步中,下载适用于您的 Windows 版本的 Oracle 数据访问组件 (ODAC)。截至本文发布之日,有效下载地址为:http: //www.oracle.com/technetwork/topics/dotnet/downloads/odacdeploy-4242173.html

    注意:ODAC 32 位版本适用于 32 位和 64 位。我在使用 64 位版本时遇到了几个问题。所以我可以建议直接下载32位版本。

    打开下载的 zip 文件,将下面的 dll 放在一起。我在您可以找到它们的文件夹中列出了 dll。我们稍后会将它们复制到我们的调试文件夹中。

    \instantclient_12_2\ 
        oci.dll  
        orannzsbb12.dll  
        oraocci12.dll  
        oraocci12d.dll  
        oraociei12.dll  
        oraons.dll  

    \oramts\bin\  
        oramts.dll  
        oramts12.dll  
        oramtsus.dll  

    \odp.net4\odp.net\bin\  
        Oracle.DataAccess.dll  

    \odp.net4\bin\  
        OraOps12.dll  
  • Step 2

    Use Visual Studio to create a console application and copy the dlls listed in Step 1 into the same folder as your project executable, the Debug folder. Add a reference to “Oracle.DataAccess.dll” by browsing to your Debug folder where you have just copied this dll into.

  • 第2步

    使用 Visual Studio 创建控制台应用程序,并将步骤 1 中列出的 dll 复制到与项目可执行文件相同的文件夹中,即 Debug 文件夹。通过浏览到您刚刚将此 dll 复制到的 Debug 文件夹,添加对“Oracle.DataAccess.dll”的引用。

It worked for me (PC with Oracle Client Installed):

它对我有用(安装了 Oracle 客户端的 PC):

    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Name                            Date modify         Size        Version           Folder                      Type                  
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Oracle.DataAccess.dll           24/05/2017 16:46    2.100 KB    4.122.1.0         
  • Browse to odp.net4 folder (With bulk insert support)

  • Copy this files to ouptut bin folder:

  • 浏览到 odp.net4 文件夹(支持批量插入)

  • 将此文件复制到输出 bin 文件夹:

    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Name                            Date modify         Size        Version           Folder                      Type                  
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    oci.dll                         13/02/2017 23:31    1.270 KB    12.2.0.0          InstantClient_12_2          Extens?o de aplicativo    
    ociw32.dll                      13/02/2017 22:20      346 KB    11.1.0.1          InstantClient_12_2          Extens?o de aplicativo    
    orannzsbb12.dll                 05/12/2016 18:38    4.329 KB    12.2.0.1          InstantClient_12_2          Extens?o de aplicativo    
    oraocci12.dll                   13/02/2017 21:29    1.006 KB    12.2.0.1          InstantClient_12_2          Extens?o de aplicativo    
    OraOps12.dll                    24/05/2017 16:45      433 KB    2.122.1.0         InstantClient_12_2          Extens?o de aplicativo    

  • OBS: In my case it′s not necessary:
  • OBS:就我而言,没有必要:
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Name                            Date modify         Size        Version           Folder                      Type                  
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Oracle.ManagedDataAccess.dll    24/05/2017 16:07    4.763 KB    4.122.1.0