Learning While Aging

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://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.

0 0 votes
Article Rating
27 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Vinay Jadon
Vinay Jadon
14 years ago

Still the problem exists…after implement your given solutiioin

Tom Austin
Tom Austin
14 years ago

Thanks. Worked like a charm.

qaywsx
qaywsx
14 years ago

Tanks for this. It helped me …

David Kocur
14 years ago

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
Meenakshi
14 years ago

It worked… thanks

Mike
Mike
14 years ago

Worked perfectly. Thanks

Jayse
Jayse
14 years ago

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

Qamar Abbas
14 years ago

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
Sil
14 years ago

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

Sil

Shamsher
Shamsher
14 years ago

Thanks…….

Manutosh
Manutosh
13 years ago

Thanks it works.

Mc Floyd
Mc Floyd
13 years ago

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
Moiz Tankiwala
13 years ago

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
Kishore
13 years ago

Thanks Provided a solution and helped me.

Kunal Gupta
Kunal Gupta
13 years ago

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
13 years ago

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

Sridhar
Sridhar
13 years ago

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

Thanasit V.
Thanasit V.
13 years ago

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
Murali
12 years ago

It helped boss… Thank you

Salah hamood
Salah hamood
11 years ago

I really Thank U …. 

nik
nik
11 years ago

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
Mohan
11 years ago

i have also solved my problem thanks all

Vo Hoai Son
Vo Hoai Son
11 years ago

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

Sujit
Sujit
11 years ago

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!