BadImageFormatException while using Oracle Client 64 bit and Visual Studio 2010!

oracle11goracleclientvisual studio 2010windows 7windows-7-x64

One of our dev team member got an error

Attempt to load oracle client libraries threw BadImageFormatException

It seems

This problem will occur when running in 64 bit mode with the 32 bit Oracle client components installed.

But it was me who configured the system – Here's the specifications:

  • Windows 7 64-bit
  • Visual Studio 2010 Premium
  • Oracle Client 11g R2 64Bit installed as Runtime

Any thoughts?

Best Answer

I am sorry about adding a second answer but if you have 64 bit and 32 bit clients installed in the same machine you may encounter this problem too.

Two clients installed

C:\oracle\product\11.2.0\client32Bit
C:\oracle\product\11.2.0\client64Bit

Control your path Environment Variable. Which Oracle client is first, it is loaded before other one.

 echo %PATH%
 XXXX;C:\oracle\product\11.2.0\client64Bit\BIN;XXX

Since my 64bit Oracle Client is first in PATH, VS.NET tries to use it for Oracle Connections and throws Bad Image Exception.

  set PATH=C:\oracle\product\11.2.0\client32Bit\BIN;%PATH%
  REM Visual Studio 2008
  "C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe"
  REM Visual Studio 2010
  "C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"

After this you can connect oracle. Of course you can put 32Bit client first in path but I prefer to put 64 bit client before 32 bit for other applications.

Related Topic