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.
The fastest way to see if an Oracle Client is 64bit or 32bit, too look for "lib32" and "lib" folders under ORACLE_HOME. If the Oracle Client is 32 bit, it will contain a "lib" folder; but if it is a 64 bit Oracle Client it will have both "lib" and "lib32" folders. Also, starting in Oracle 11.2.
You can install Oracle 32-bit and Oracle 64-bit on the same server. The two installs must reside in different ORACLE_HOME directories though. So install Oracle 32-bit in a different directory than your 64-bit version and they will both coexist quite nicely.
Data. OracleClient is a Microsoft . NET data provider allowing you to connect to an Oracle database. The provider is deprecated and it should not be used - Oracle and ADO.NET.
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.
I had the same problem you have. I found most of my answers through Oracle forums and here at stackoverflow. I can't post links for reference but I can give you some things to try out.
See if the exception goes away.
FYI, Microsoft is dropping Oracle data provider (in ADO.NET) support in the near future. It currently works through .NET 4, but it is a good idea to start testing the native Oracle drivers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With