How to fix System.Data.OracleClient BadImageFormatException error

[UPDATE]: The fix in this post may not work on Windows Vista/7  64-bit operating system, if you are using Vista/7 and have the problem specified in this post, then check out the updated post here: https://www.learningpenguin.net/index.php/2010/08/13/update-how-to-fix-system-data-oracleclient-badimageformatexception-error/

If you use Microsoft’s OracleClient libraries to connect Oracle database in .NET application, you may encounter BadImageFormatException error if the application is running on a x64 machine. The actual error message shows as follows:

[InvalidOperationException: 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.]

You can follow the following steps to fix the error:

1. In Visual Studio, right click your project from the Solution Explorer and click “Properties”.

2. Click Compile tab on the left, then click Advanced Compile Options.

20090921_154148

 

3. From Target CPU drop down list, change Any CPU to x86.

20090921_154240_thumb

 

4. Click OK to accept the changes, then rebuild the application.

It should fix the above exception error.

27
Leave a Reply

avatar
27 Comment threads
0 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
26 Comment authors
SujitVo Hoai SonMohannikSalah hamood Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Vinay Jadon
Guest
Vinay Jadon

Still the problem exists…after implement your given solutiioin

Tom Austin
Guest
Tom Austin

Thanks. Worked like a charm.

qaywsx
Guest
qaywsx

Tanks for this. It helped me …

David Kocur
Guest

Thank you!
In my case the program was installed in the 32 bit program directory.  I would’ve thought that would be enough for Microsoft to run it in 32 bit mode, but apparently that’s not the case.

Meenakshi
Guest
Meenakshi

It worked… thanks

Mike
Guest
Mike

Worked perfectly. Thanks

Clody
Guest
Clody
Jayse
Guest
Jayse

Worked. Had to go to Project -> Properties -> Build -> Target CPU. Just changing the Target Platform in the toolbar didn’t work.

Qamar Abbas
Guest

Thanks who wtrote the following quote
“Enable 32-bit Application” to True
i appreciate him.
I m also thanks to all peoples who write there problem solutions.

Sil
Guest
Sil

Thanks a lot for this post Jeffery.
It solved my problem.

Sil

Shamsher
Guest
Shamsher

Thanks…….

Manutosh
Guest
Manutosh

Thanks it works.

Mc Floyd
Guest
Mc Floyd

Woohoo!! it worked for me. I’m using SQL Server 2005, VS2005, and Oracle 10g, 32-bit Client, under Windows 7 Enterprise.

I was able to run from VS and it connected to Oracle successfully.

Thanks for the post!!!

Moiz Tankiwala
Guest
Moiz Tankiwala

I tried your solution, but set the compilation output to x64 and it worked like a charm on windows 2008 x64 enterprise edition.
Source environment: I was compiling the source code on Windows Server 2003 32-bit edition.
Thanks for the solution.

Kishore
Guest
Kishore

Thanks Provided a solution and helped me.

Kunal Gupta
Guest
Kunal Gupta

Hi,
I am using a Windows Server 2008 R2 Enterprise OS on a 64 Bit machine.
I tried setting Target CPU to X86 and also X64, but, in both case it didn’t worked 🙁 🙁
Any solution?

Guest
Guest
Guest

Thanks for the suggestion. It solved my issue. I am using actually Oracle Instant Client with Windows 7

Sridhar
Guest
Sridhar

Thanks so much Jeffery. It worked for me!!!

Thanasit V.
Guest
Thanasit V.

Thank you Jeffery. It works for me too.
My environment is :
1. Windows 2008 Server 64 bit
2. Oracle client 11gR2 32 bit
3. Oracle client 11gR2 64 bit (Automatically installed with Oracle BIEE 11gR2 64 bit)

Murali
Guest
Murali

It helped boss… Thank you

Salah hamood
Guest
Salah hamood

I really Thank U …. 

nik
Guest
nik

Hi

I cant even find property in visual studio 2010.

please help me out.I am not able to find Advanced Compiler section too.

 

Mohan
Guest
Mohan

i have also solved my problem thanks all

Vo Hoai Son
Guest
Vo Hoai Son

Thanks , very much. I use vs 2012 , Oracle 10g. Win 7 Ultimate 64 bit. It fixed

Sujit
Guest
Sujit

Hi,

Am runing a console application in Window 2008 server am geting the below 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.

Could any one please help!