I am trying to run a .NET application which uses System.Data.OracleClient
on a Win7 x64 workstation. The workstation has a 32bit Oracle client installed, which leads to the following error message:
Attempt to load Oracle client libraries threw BadImageFormatException. This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.
So this is my long journey of tries and failures:
System.Data.OracleClient
) and saw that DllPath points to the correct x64 installation of ODAC, so, if my application wasn't using System.Data.OracleClient
, it should work,b but since it does use that, it still failed.After getting the first answer from b_levitt, I tried and added the following lines to the Global.asax at Application_Start
:
Environment.SetEnvironmentVariable("ORACLE_HOME", @"C:\OracleProducts\Odac-11.2.0.2.1-x64");
Environment.SetEnvironmentVariable("PATH", @"C:\OracleProducts\Odac-11.2.0.2.1-x64;C:\OracleProducts\Odac-11.2.0.2.1-x64\bin");
C:\OracleProducts\Odac-11.2.0.2.1-x64 is where I installed the ODAC 64 bit xcopy version. No success either.
On a related note, I even tried to force my .NET app into 32bit mode without success, but that's a different thing. I need a forward-looking solution, which means 64bit.
Your #5 should have worked but you also need to set the ORACLE_HOME environment variable. I've done this many times including recently with the very xcopy install that you are using. Please check out my experience with the xcopy install and let me know what kind of additional errors that you get.
In my case I was setting it up for asp.net, but winforms is even easier. You can open a cmd window, use the "set" command to set both the PATH and the ORACLE_HOME environment variables and then run your app from that same cmd window. Once you get the bugs worked out, you can use the Environment.SetEnvironmentVariable to set these within your code.
For the record, I do avoid installing the oracle client on client machines by handling all of the business logic via web services. That way I only need the oracle components on the web server.