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

发布于 2024-12-10 14:38:38 字数 162 浏览 1 评论 0原文

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

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

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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

公布 2024-12-17 14:38:38

Oracle 的 Alex Keh 在 2013 年 8 月说道:

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

目前,我们正在打包一个独立管理的 ODP.NET 版本并
ODAC 12 版本将会小得多。这将发布于
很快就会有 OTN。

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

====

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

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

Nuget 管理的 ODP.NET

PM> Install-Package Oracle.ManagedDataAccess

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

  • 安装占用空间大(数百 Mb)
  • 难以部署到远程计算机 - 需要安装 ODP客户端上的.NET
    机器或部署大文件
  • 在使用多个版本、32 位/64 位操作系统和应用程序时具有挑战性

那是什么?

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

主要优点:

  • 占用空间小
  • 可作为任何 cpu 编译,因此可以在 32 位/64 位操作系统上运行
    并顺利申请。轻松管理多个版本
    同一台机器
  • 可以部署为应用程序中的简单参考
    bin 目录。

那么有什么问题吗?

  • 并非所有功能都受支持(尽管大多数功能都是......)
    上找到更多信息
  • 可以在文档
    Oracle.DataAccess.Client 到 Oracle.ManagedDataAccess.Client
  • 性能差异仍不清楚。 (旧)本机代码
    始终执行非常高效,但另一方面 100% 得到管理
    代码有其性能优势。

请注意,本机代码 ODP.NET 仍然非常可用。除了本机版本之外,还提供了托管版本(至少目前如此)。

参考文献: http://oracleatdotnet.blogspot.com .es/2013/07/odpnet-management-driver-beta-2.html

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

Oracle Data Provider for .NET 的功能
http://docs.oracle.com/database/121/ODPNT/features .htm#ODPNT0007

Alex Keh from Oracle in aug 2013 says:

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

====

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

Nuget managed 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:

  • 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

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.

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.

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.

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.

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

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

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

雪化雨蝶 2024-12-17 14:38:38

您也可以使用 NuGet 来托管 ODP.NET https://www.nuget.org/ packages/odp.net.management/

PM> Install-Package odp.net.managed 

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

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


更新:

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

或包经理控制台

PM> Install-Package Oracle.ManagedDataAccess

you can get managed ODP.NET using NuGet too 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)

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/

Or Package Manager Console

PM> Install-Package Oracle.ManagedDataAccess
指尖凝香 2024-12-17 14:38:38

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

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

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

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

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

The ODP.NET does require native OCI DLLs (~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.

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

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.

完美的未来在梦里 2024-12-17 14:38:38

最新的 ODAC 版本附带 Oracle 即时客户端,因此您无需安装完整的客户端。

(32 位版本)

(64 位版本)

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

(32 bit release)

(64 bit release)

云朵有点甜 2024-12-17 14:38:38

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

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

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

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

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

ODP.net managed driver is released now.

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

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

め可乐爱微笑 2024-12-17 14:38:38

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

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

无风消散 2024-12-17 14:38:38

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

编辑:

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

感谢 Iron Automation:

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

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

请按照以下步骤操作:

  • 第 1 步

    我们需要 Oracle 提供的一组 dll 来在我们的项目中使用。因此,在第一步中,请下载适合您的 Windows 版本的 Oracle 数据访问组件 (ODAC)。截至本文发布之日,有效的下载 URL 为: 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\4\  
        Oracle.DataAccess.dll  

    \odp.net4\bin\  
        OraOps12.dll  
  • 步骤 2

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

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

    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Name                            Date modify         Size        Version           Folder                      Type                  
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Oracle.DataAccess.dll           24/05/2017 16:46    2.100 KB    4.122.1.0         
  • 浏览到 odp.net4 文件夹(支持批量插入)

  • 将此文件复制到 ouptut 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:就我而言,没有必要:
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Name                            Date modify         Size        Version           Folder                      Type                  
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Oracle.ManagedDataAccess.dll    24/05/2017 16:07    4.763 KB    4.122.1.0         

It worked for me (PC without Oracle Client):

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;

Thanks to Iron Automation:

Link: 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.

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.

    \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\4\  
        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.

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

    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    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:

    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    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:
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Name                            Date modify         Size        Version           Folder                      Type                  
    ------------------------------- ------------------- ----------- ----------------- --------------------------- ----------------------- 
    Oracle.ManagedDataAccess.dll    24/05/2017 16:07    4.763 KB    4.122.1.0         
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文