tags:

views:

3480

answers:

8

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.

+3  A: 

ODAC xcopy will get you away with about 45MB. http://www.oracle.com/technology/software/tech/windows/odpnet/index.html

+4  A: 

DevArt http://www.devart.com/, formerly CoreLab (crlab.com) supplies a pure-C# Oracle client. That's a single dll, and it works fine.

That's very close to what I want, actually. Ideally, I'd like an Oracle only solution, but I am investigating this one.
Jonathan
And it does not require a local Oracle Client installation?
Ishmaeel
+23  A: 

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

Mac
using Visual Studio 2005, I have had success without performing steps 4 or 5
Timothy Carter
Is it ok to just include the dlls with your app in terms of licensing?
thecoop
Instant Client is licensed under the OTN Development and Distribution License (cf. http://www.oracle.com/technology/software/htdocs/client_lic.html). Which means you can freely redistribute it with your application (cf. http://www.oracle.com/technology/tech/oci/instantclient/ic-faq.html#A4379).
Mac
A: 

Does anyone know the exact names of the files in 11_1 ver.6 and ver.7 that are necessary as they seem to be different than those above?

I am trying to deploy the 3 files, plus the CRT, plus the DataAccess dll as content in WPF application.

I don't care about re-usability since the client will only be about 19mb and rarely updated at all. I just need to have it deployed with the application so that I can use ClickOnce and not touch their registry etc.

-T

twhite @ fire . ca . gov

I updated my answer for v11. Sorry for the delay, but there is no way I could be notified of your answer. You should have left a comment...
Mac
A: 

closer still.

I am using Instant Client 11.1.0.6 and Oracle.DataAccess.dll included in 11.1.0.6.21.

I have copied all the .dlls and the crt dll from the instant client folder into the root of my project, set them as Content to be Copy Always.

ClickOnce is adding them to the manifest and from what I can tell they are located in the same folder as the EXE for my app is, so path should not be an issue.

I get an immediate XamlParseException on InitializeComponent() within my MainWindow.xaml file... this means nothing, and on debugging i find the inner-most exception causing it all is an OracleException stating:

"The provider is not compatible with the version of Oracle client"

From what I understand this usually means someone either has 1) multiple clients installed, 2) the wrong instant client and dataaccess.dll matched up, or 3) the client isn't being found at all.

Looking at the libraries I am using my guess is #3... any thoughts?

Two other things to note

  • It works fine on my machine both in VS.Net and when deployed to my box by ClickOnce - but I also have a full client installed so I am guessing it is using that.'
  • The connectionString in my app config looks exactly like a TNSNAMES.ORA entry rather than the uber simple EZCONNECT.

Any help you got Mac would be awesome. I'm thoroughly stuck and got some deadlines coming soon... if I can't use clickonce and this instant client, i have to dump my whole project for WinForms and Terminal Server bullshizzle.

twhite @ fire . ca . gov

+1  A: 

The answer provided was a huge help though I'm new and unable to bump it yet.

Though it is slightly off topic, this is one of the closest places I found help for my situation. Please disregard my noob questions above; I've learned a lot on the topic in the last couple months and have a little more information that may prove useful in addition to Mac's good advice.

1. First, Mac is right, you do need MSVCR71.dll.

2. I was using the 11.0.6/11.0.7 instant client, so the filenames were slightly different. It took a few more, but the shaved size was still around 30mb: * oci.dll * ociw.dll * orannzsbb11.dll * oraocci11.dll * oraociicus11.dll * oraops11w.dll

3. My connection string looks like a standard .Net connection string, with the following exception - my Data Source value looks like the TNSNAMES.ORA entry. It works great.

I was deploying a WPF/C# application via ClickOnce. In order to get it to work, these files were included in my project as Content and deployed Copy Alyways. Placing them at the root of my project avoided any Path issues and it seems to work great. However, machines aside from XP seems to bail. I'm not sure what this limitation is yet. But my guess is the instant client I am using doesnt like either Windows 2003/2008/7, or perhaps more acurately, 64-bit OSes.

Trey
+3  A: 

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

Fidel
+1  A: 

I found this post on the Oracle forum very usefull as well:

How to setup Oracle Instant Client with Visual Studio

Remark: the ADO.NET team is deprecating System.Data.OracleClient so for future projects you should use ODP.NET

Reproduction:

Setup the following environment variables:

  1. make sure no other oracle directory is in your PATH
  2. set your PATH to point to your instant client
  3. set your TNS_ADMIN to point to where you tnsnames.ora file is located
  4. set your NLS_LANG
  5. set your ORACLE_HOME to your instant client

For me, I set NLS_LANG to

http://download-east.oracle.com/docs/html/A95493%5F01/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

Vincent