将C#连接到Oracle数据库所需的最小客户端占用空间是多少?

时间:2020-03-05 18:55:28  来源:igfitidea点击:

通过在笔记本电脑上下载并安装客户端管理工具和Visual Studio 2008,我已经成功地从C(Visual Studio 2008)连接到Oracle数据库(10g)。

Oracle客户端工具的安装空间超过200Mb,而且运行时间很长。

有谁知道最小可行的占用空间是多少?我希望这是一个DLL和一个register命令,但是我感觉需要安装一个oracle home,并设置各种环境变量。

我在代码中使用Oracle.DataAccess。

解决方案

回答

ODAC xcopy将为我们提供约45MB的存储空间。
http://www.oracle.com/technology/software/tech/windows/odpnet/index.html

回答

DevArt http://www.devart.com/,以前是CoreLab(crlab.com)提供纯COracle客户端。那是一个单一的dll,并且工作正常。

回答

我们需要一个Oracle Client才能连接到Oracle数据库。最简单的方法是安装Oracle数据访问组件。

为了最大程度地减少占用空间,我建议采取以下措施:

  • 使用框架附带的用于Oracle的Microsoft提供程序(System.Data.OracleClient)。
  • 下载Oracle Instant Client软件包-Basic Lite:这是一个(几乎)最低要求的zip文件。我建议使用10.2.0.4版,该版本比11.1.0.6.0版小得多。
  • orannzsbb10.dll
  • oraociicus10.dll
  • orannzsbb11.dll
  • oraociei11.dll
  • 在x86平台上,将Visual Studio 2003的CRT DLL(msvcr71.dll)添加到此文件夹,因为Oracle伙计们忘记阅读此文件了。
  • 将此文件夹添加到PATH环境变量中。
  • 在应用程序中使用Easy Connect Naming方法来摆脱臭名昭著的TNSNAMES.ORA配置文件。它看起来像这样:sales-server:1521 / sales.us.acme.com

总计约19Mb(v10)。

如果我们不希望在多个应用程序之间共享此文件夹,则可以选择将上述DLL与应用程序二进制文件一起提供,并跳过PATH设置步骤。

如果我们绝对需要使用Oracle提供程序(Oracle.DataAccess),则需要:

  • ODP .NET 11.1.0.6.20(据称可与Instant Client一起使用的第一个版本)。
  • 显然,Instant Client 11.1.0.6.0。

请注意,我尚未测试此最新配置...

回答

通过这种方式,我们可以使用来自oracle的5个可再发行文件与ODP.net连接:

克里斯的博客文章:使用新的ODP.Net通过简单的部署即可从C访问Oracle

编辑:万一每个博客都失败了,这里是一个简短的摘要...

  • oci.dll
  • Oracle.DataAccess.dll
  • oraociicus11.dll
  • OraOps11w.dll
  • orannzsbb11.dll
  • oraocci11.dll
  • ociw32.dll
make sure you get ALL those DLL's from the same ODP.Net / ODAC distribution to avoid version number conflicts, and put them all in the same folder as your EXE

回答

我在Oracle论坛上也发现了这篇文章非常有用:

如何使用Visual Studio设置Oracle Instant Client

备注:ADO.NET团队不赞成使用System.Data.OracleClient,因此对于以后的项目,我们应该使用ODP.NET

再生产:

Setup the following environment variables:
  
  
  make sure no other oracle directory is in your PATH
  set your PATH to point to your instant client
  set your TNS_ADMIN to point to where you tnsnames.ora file is
  located
  set your NLS_LANG
  set your ORACLE_HOME to your instant client
  
  
  For me, I set NLS_LANG to 
  
  http://download-east.oracle.com/docs/html/A95493_01/gblsupp.htm#634282
  
  I verified this was using the correct client software by using the sqlplus add-on to the instant client.
  
  For me, I set:
  SET NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252
  
  Note: before you make any changes, back up your Oracle registry key (if exist) and backup the string for any environment variables.
  
  Read the Oracle Instant Client FAQ here