How to force .NET application to run in 32bit mode

Viewed 20043

I am trying to run my .NET 3.5 WinForms application on a Win7 x64. The application uses NHibernate and the System.Data.OracleClient to access an Oracle database. The Oracle client is 32bit.

When starting up the app I get the following 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.

In response to that, I targetted my build to the x86 platform:

Screenshot of the Build settings

To my surprise, the very same error message appeared when trying to execute that new build on the Win7 platform.

The NHibernate assembly is loaded at runtime by Assembly.Load("...");.

Could it be that the NHibernate DLL still runs in 64 bit mode whilst the host exe runs in 32 bit mode. That sounds strange to me. Or could it be that for whatever reason, my application runs in 64 bit mode even though it was targeted to x86?


Update:

I checked my binary using CorFlags, and it is marked 32 bit:

Microsoft (R) .NET Framework CorFlags Conversion Tool.  Version  4.0.30319.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Version   : v2.0.50727
CLR Header: 2.5
PE        : PE32
CorFlags  : 3
ILONLY    : 1
32BIT     : 1
Signed    : 0

I also checked it in Task Manager, and it has a *32 suffix.

I also tried and used CorFlags to add the 32bit flag to all assemblies that come with my application. It still yields the same error message.

I'm puzzled... puzzled... puzzled...

6 Answers
Related