Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

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

3.00/5 (2 votes)
19 Dec 2010CPOL1 min read 90.9K  
ASP.NET website project hosted on IIS 7.5 running on Windows 2008 R2 is unable to connect to ‘Oracle’ database.

Problem Statement


"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."


Reason 1#


There could be a possibility that Oracle Client 64 bit(drivers) is not installed properly on Windows 2008 r2. This improper installation of Oracle Client doesn't affect connectivity with Oracle for .NET Windows or Console application. It affects only Web based applications.


Solution


To check whether Oracle Client is installed properly or not, follow the following steps.



  1. Create one UDL file: Create one text file and name it as "conn.udl".
  2. Open conn.udl file. By opening that file, you will see a window as shown below:

  3. Select "Microsoft OLE DB Provider for Oracle" and click on Next button which will take you to the next tab "Connection".
  4. In this Connection tab, Give Database server name, User name and password and click on Test Connection. If all the Credentials are correct and required TNS entry is there in tnsnames.ora file, then it will give a connection successful message as shown below. If this message is coming, then Oracle Client installation is done properly.


Conclusion


Connectivity of ASP.NET With Oracle Client can be because of improper installation of Oracle Client on the server. So this is the basic Check we can do to verify it.


License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)