[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.
3. From Target CPU drop down list, change Any CPU to x86.
4. Click OK to accept the changes, then rebuild the application.
It should fix the above exception error.
Still the problem exists…after implement your given solutiioin
Thanks. Worked like a charm.
Tanks for this. It helped me …
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.
It worked… thanks
Worked perfectly. Thanks
corflags /32bit+ programm.exe
http://blogs.intesoft.net/post/2007/12/Running-NET-Apps-in-32-bit-mode-on-64-bit-Windows.aspx
Worked. Had to go to Project -> Properties -> Build -> Target CPU. Just changing the Target Platform in the toolbar didn’t work.
@Clody,
Thanks for the info. However, I would rather change IIS settings to enable 32-bit application to run in 64-bit Windows. All you need to do is go to the Application Pool that your aplication is running under, then under Advanced Settings, change “Enable 32-bit Application” to True, and you are done. No change in your application is needed, no third-party tool is needed.
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.
Thanks a lot for this post Jeffery.
It solved my problem.
Sil
Thanks…….
Thanks it works.
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!!!
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.
Thanks Provided a solution and helped me.
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?
@Kunal,
For Windows Vista, 7 and Windows Server 2008 64bit OS, you will have to use Oracle’s ODP.NET instead of Microsoft’s OracleClient dll. https://learningpenguin.net/blog/index.php/2010/08/13/update-how-to-fix-system-data-oracleclient-badimageformatexception-error/
Thanks for the suggestion. It solved my issue. I am using actually Oracle Instant Client with Windows 7
Thanks so much Jeffery. It worked for me!!!
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)
It helped boss… Thank you
I really Thank U ….
Hi
I cant even find property in visual studio 2010.
please help me out.I am not able to find Advanced Compiler section too.
i have also solved my problem thanks all
Thanks , very much. I use vs 2012 , Oracle 10g. Win 7 Ultimate 64 bit. It fixed
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!