4

I'm working on an Excel Addin (VSTO) in .NET that connects to an Oracle 10g database.

I'm running on Vista x64 and have figured out that I need both the x86 and x64 Oracle clients installed on my machine so that both 32 bit processes (like PL/SQL Developer) and 64 bit processes (like an example .NET console app compiled for "Any CPU") can connect to Oracle.

That's all working fine. My problem is that Excel is a 32 bit app hosting a .NET DLL and, according to ProcessMonitor the excel process is loading the "OraClient10g_home1" Oracle client at "C:\oracle\product\10.2.0\client_1\BIN\oci.dll" (which happens to be the 64 bit client) and that gives me a BadImageFormatException when my .NET code tries to use it.

What I want is to tell .NET to load the 32 bit "OraClient10g_home2" Oracle client (i.e. "C:\oracle\product\10.2.0\client_2\BIN\oci.dll"). How can I tell .NET to use client_2 instead of client_1.

d4nt
  • 15,475
  • 9
  • 42
  • 51

2 Answers2

4

Try changing the DllPath in HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOME\ODP.NET.

Blair
  • 3,671
  • 4
  • 29
  • 40
  • 1
    You can change it in the app.config too. http://download.oracle.com/docs/html/E10927_01/InstallODP.htm – Christian13467 Sep 23 '09 at 08:56
  • This is what I did in the end – d4nt Sep 25 '09 at 19:31
  • You say you are using the Microsoft provider for Oracle (System.Data.OracleClient). I am very surprised (to say the least) that setting this parameter that is specific to the Oracle provider (Oracle.DataAccess) should solve your problem. – Mac Sep 28 '09 at 08:23
  • @d4nt, another surprised reader of this. I've even doublechecked, and it my DllPath already has the right path but it still wouldn't work. – chiccodoro Jul 22 '11 at 13:25
  • The OracleClient classes you get with ADO.NET are not a 'complete' Oracle client, you still have to install the Oracle client stuff on your machine to make it work. So I'm assuming that the ADO.NET OracleClient classes just call through to oci.dll. That's why I observed the oci.dll being loaded in process monitor and why it's important which version .NET is pointing at. – d4nt Jul 26 '11 at 22:05
2

You could :

Community
  • 1
  • 1
Mac
  • 8,191
  • 4
  • 40
  • 51
  • That's great. How exactly do I tell .NET to use the instant client? – d4nt Sep 23 '09 at 08:26
  • Just ship it along your application : http://stackoverflow.com/questions/70602/what-is-the-minimum-client-footprint-required-to-connect-c-to-an-oracle-database – Mac Sep 23 '09 at 10:22
  • 1
    That tells me how to package the oracle client, but how do we tell .net to use those DLLs that we've included in our app as opposed to the Full client that is installed on my PC. I don't see how having the instant client in a folder will change what .net uses? – d4nt Sep 25 '09 at 19:35
  • Because of the way DLLs are loaded on the Windows platform : the application folder is searched first, then the %PATH%. I'll get you a link as soon as I can (I'm on my phone right now). – Mac Sep 26 '09 at 00:04
  • There you go (slightly more complicated that what I said in my previous comment, but that was the spirit of it) : http://msdn.microsoft.com/en-us/library/ms682586%28VS.85%29.aspx – Mac Sep 28 '09 at 08:27