What is the minimum client footprint required to connect C# to an Oracle database?

I have successfully connected to an Oracle database (10g) from C# (Visual Studio 2008) by downloading and installing the client administration tools and Visual Studio 2008 on my laptop.

The installation footprint for Oracle Client tools was over 200Mb, and quite long winded.

Does anyone know what the minimum workable footprint is? I am hoping that it's a single DLL and a register command, but I have the feeling I need to install an oracle home, and set various environment variables.

I am using Oracle.DataAccess in my code.


Solution 1:

You need an Oracle Client to connect to an Oracle database. The easiest way is to install the Oracle Data Access Components.

To minimize the footprint, I suggest the following :

  • Use the Microsoft provider for Oracle (System.Data.OracleClient), which ships with the framework.
  • Download the Oracle Instant Client Package - Basic Lite : this is a zip file with (almost) the bare minimum. I recommend version 10.2.0.4, which is much smaller than version 11.1.0.6.0.
  • Unzip the following files in a specific folder :
    • v10 :
      • oci.dll
      • orannzsbb10.dll
      • oraociicus10.dll
    • v11 :
      • oci.dll
      • orannzsbb11.dll
      • oraociei11.dll
  • On a x86 platform, add the CRT DLL for Visual Studio 2003 (msvcr71.dll) to this folder, as Oracle guys forgot to read this...
  • Add this folder to the PATH environment variable.
  • Use the Easy Connect Naming method in your application to get rid of the infamous TNSNAMES.ORA configuration file. It looks like this : sales-server:1521/sales.us.acme.com.

This amounts to about 19Mb (v10).

If you do not care about sharing this folder between several applications, an alternative would be to ship the above mentioned DLLs along with your application binaries, and skip the PATH setting step.

If you absolutely need to use the Oracle provider (Oracle.DataAccess), you will need :

  • ODP .NET 11.1.0.6.20 (the first version which allegedly works with Instant Client).
  • Instant Client 11.1.0.6.0, obviously.

Note that I haven't tested this latest configuration...

Solution 2:

I use the method suggested by Pandicus above, on Windows XP, using ODAC 11.2.0.2.1. The steps are as follows:

  1. Download the "ODAC 11.2 Release 3 (11.2.0.2.1) with Xcopy Deployment" package from oracle.com (53 MB), and extract the ZIP.
  2. Collect the following DLLs: oci.dll (1 MB), oraociei11.dll (130 MB!), OraOps11w.dll (0.4 MB), Oracle.DataAccess.dll (1 MB). The remaining stuff can be deleted, and nothing have to be installed.
  3. Add a reference to Oracle.DataAccess.dll, add using Oracle.DataAccess.Client; to your code and now you can use types like OracleConnection, OracleCommand and OracleDataReader to access an Oracle database. See the class documentation for details. There is no need to use the tnsnames.ora configuration file, only the connection string must be set properly.
  4. The above 4 DLLs have to be deployed along with your executable.

Solution 3:

As of 2014, the OPD.NET, Managed Driver is the smallest footprint.

Here is a code usage comparison to the non-managed versions that previous (outdated) answers suggested: http://docs.oracle.com/cd/E51173_01/win.122/e17732/intro005.htm#ODPNT148

You will need to download these dlls and reference Oracle.ManagedDataAccess.dll in your project: Download the ODP.NET, Managed Driver Xcopy version only

Here is a typical foot print you will need to package with your release:

  1. Oracle.ManagedDataAccess.dll
  2. Oracle.ManagedDataAccessDTC.dll

all together, a whopping 6.4 MB for .Net 4.0.

Solution 4:

This way allows you to connect with ODP.net using 5 redistributable files from oracle:

Chris's blog entry: Using the new ODP.Net to access Oracle from C# with simple deployment

Edit: In case the blog every goes down, here is a brief summary...

  • 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