How to specify what version of the Oracle client to use in .Net

I’ve been having quite the time recently getting old code, old Oracle databases and old Oracle database drivers to work alongside new code, new databases and new database drivers.  Some of the issues I’ve had are:

1) Microsoft wrote a oracle driver for .Net which they have now deprecated
2) Oracle doesn’t seem willing to allow downloads of version 9.x from their website, if you can figure out where to download it from, let me know.
3) .Net 2010 needs a recent version of the Oracle driver (around ver 11.2.0.1.2) to replace the now deprecated Microsoft one.  Unfortunately when installed the new driver won’t connect to old databases.  Most of the databases I use are recent, but there is one I can’t connect to with 11.x
4) Oracle used to use a Oracle_Base folder to tell a machine what the default version of Oracle on it was.  They seem to be moving away from this approach but the old base dir still haunts.  My old VB6 apps for example are stuck in their ways and won’t use anything but the base version.

There’s more, but I’ll leave it at that for now.  Finally I found some details on how I can make this nightmare a little less frightening.  Firstly make Oracle 9.x the “Base” version, then in your .Net apps you can specify what version to use.  To do this modify your web or app config files, add this XML just before the closing </configuration> tag:

<oracle.dataaccess.client>
<settings>
<add name="DllPath"               value="C:\ORACLE\Base\product\11.2.0.1.2\client\bin"/>
<add name="FetchSize"             value="65536"/>
<add name="PromotableTransaction" value="promotable"/>
<add name="StatementCacheSize"    value="10"/>
<add name="TraceFileName"         value="C:\ORACLE\Base\product\11.2.0.1.2\client\odpnet2.trc"/>
<add name="TraceLevel"            value="63"/>
<add name="TraceOption"           value="1"/>
</settings>
</oracle.dataaccess.client>

Note: the paths have to be valid for your machine.

To make this process even easier, instead of modifying your web or app config you can modify your machine config.  This will affect all .Net apps written for a given .Net version.  EG modify this file:
c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config
With the same method mentioned above.  Now all 4.0 .Net apps will use that Oracle version by default.  They can still override that by putting a different one in their app or web config.

More info on managing Oracle installations can be found here:
http://download.oracle.com/docs/html/E10927_01/InstallODP.htm

Leave a comment