C# – System.Data.OracleClient not working with 64 bit Oracle Client

cnetoracleoracle10goracle11g

I have designed a C# application to connect to Oracle Database and change schema users passwords. My reference assembly is System.Data.OracleClient from the location: "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\System.Data.OracleClient.dll"

The platform that I used to design/test the application looks like this:
1. 64 bit Windows 7 platform.
2. 32 bit .Net Frameworkv4.5
3. 32 bit Oracle 10g Client.

I need this application to run for 64 bit Oracle Client too. But when I transfer my binaries to a machine which has 64 bit Oracle 11g installed, I get this error: "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."

I am not sure how to work around this issue. Please suggest if I need to make any code changes or assembly reference. I read through a lot of similar forums but could not find anything helpful. Please help!

Best Answer

First of all, provider System.Data.OracleClient is deprecated. Microsoft is not supporting it anymore, you should consider to use the Oracle provider Oracle.DataAccess or Oracle.ManagedDataAccess.

My recommondation is to install both, 32-bit and 64-bit Oracle Client on your developing machine, then you can test and build anything. Here is an instruction how to do this: Install x86 and x64 Oracle Client on one machine

An x86 Oracle client can connect to a 64 bit Oracle Database, vice versa is also no problem.

Related Topic