Skip to main content

Attempt to load Oracle client libraries threw BadImageFormatException

I came across “System.BadImageFormatException” error while trying to migrate an application from Windows Server 2008 R2 to Windows Server 2012 R2. I will list possible root cause and solution for this issue in this post.

Error message:

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.

Read More

How to find out which Oracle Client versions are installed?

If your application uses Oracle database, you will need to install the appropriate version of Oracle Client in your local machine.  As this software keeps being updated, you may find yourself trying to uninstall old versions from your system after a while. The question is that how to find which versions of Oracle Client you have in Windows?

Finding out which Oracle Client you installed it’s not straightforward. You can check PATH variables or run some commands in SQLPLUS or TNSPING. Another approach is using OPatch Utility. In this post, I will talk about a much easier way to Oracle Client versions.

Oracle Client versions

Simply run the query below in the Command Prompt. It will call PowerShell first and search for oraclient*.dll files (Asterisk is used to represent the number such as 10, 11 or 12). Once the query is executed, a nicely formatted table will be displayed with the versions and their paths.

powershell "gci C:\,D:\ -recurse -filter 'oraclient*.dll' -ErrorAction SilentlyContinue | %{ $_.VersionInfo } | ft -Property FileVersion, FileName -AutoSize"

List of Oracle Client versions
List of Oracle Client versions

Make sure to add (or remove) hard disk drives if your system has more or less than 2 drives (C: and D:). In the command, only C: and D: drives are searched.

Alternative Way

You can use the query below in SQL Developer to list the versions of the client libraries used. Please note that this query may list the version which is used by SQL Developer only.

  v$session_connect_info s
  s.sid = SYS_CONTEXT('USERENV', 'SID');

List of Oracle Client versions
Query in SQL Developer

Another approach is that querying v$version variable: select * from v$version


How to test connectivity between a server and Oracle database?

If you have a new Windows server and preparing it to host web applications, one of the first configurations you should make is to open firewall ports between your web server and database server.

In order to make sure required ports are opened, use tnsping and ODBC testing tools. These utilities can quickly tell you if the database connectivity is available.


  1. Open a Command Prompy (Start > Run > cmd)
  2. Type tnsping <servicename>
  3. If the result is OK, database connection is successful

ODBC Test Utility

  1. Open ODBC Administrator (Start > Search > ODBC)
  2. Click “Add”. Enter a service name and user ID
  3. Click “Test Connection”
  4. Enter your password when prompted. Click “OK”
  5. You should recieve “Connection successful” message

Note: Linux users can also use TRCROUTE utility. For more information, please refer to the link below.