I know there is an answered question regarding this error but the fix has not worked for me. So I am posting this in the hopes that someone can help.
I think I have tried everything to no avail.
This is my scenario:
Basics: I am running Windows 7-64-bit OS. My Visual Studio version is 2008. My Configuration Manager is set to 'AnyCPU'.
I have a WPF application that I can run on my computer that uses the 32-bit Oracle Client DLL and it can connect.
I am trying to recreate this application to a Web Application. Using the same code and configuration and DLL, I get the following error when attempting to connect to an Oracle database:
"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 have tried to change my IIS Manager Application_Pool default setting, 'Enable 32-bit Applications" from FALSE to TRUE and it still does not work.
I have tried to reference the 64-bit Oracle Client DLL in the folder ..\Framework64\OracleClient.dll and it does not work.
I have tried changing the Configuration Manager from 'AnyCPU' to 64-bit then 32-bit and it still does not work.
I am out of ideas.
Currently, my setting is Configuration Manager - AnyCPU; Application_Pool (Enable 32-bit APplications = TRUE); OracleClient DLL - 32-bit.
Which Oracle client do you have installed, specifically? Also, are you using Oracle.DataAccess.Client in your code, or System.Data.OracleClient?
The normal configuration in this case would be to set ConfigurationManager's build options to x86 to build a 32 bit application on a 64 bit OS. It likely worked in WPF anyway because Visual Studio is 32 bit, but IIS (which hosts the web application) is 64 bit. So you need to be explicit.
I am using System.Data.Client.
I believe the version is the 32-bit version. The DLL is located in the folder \Framework\v2.05727/System.Data.OracleClient.
Also, I set my IIS Application-Application Pool option, Enable 32-bit Applications to 'True'.
I changed the Configuration Manager setting from 'AnyCPU' to 'x86' and get the same error.
Alright, it sounds like something is going wrong between System.Data.OracleClient and it's attempt to load an Oracle client.
Unfotunately System.Data.OracleClient is a depreciated Microsoft provided driver, so I'm not sure what its doing or how to help you with it.
If you wanted to switch over fully to the Oracle driver, you'd need to remove that reference, add one to Oracle.DataAccess, and change your code appropriately. That's more work, but might solve the issue.