Thursday, April 14, 2011

Forcing a .NET Application to Execute as 32-bit

I recently had a requirement to force a .NET application (EXE) to execute as a 32-bit application on a 64-bit operating system. To cut a long and painful story short, I needed the application to execute as a 32-bit application because only the 32-bit version of the Oracle database client was installed, and when the application executed in its default form, it attempted (and failed) to use the 64-bit Oracle database client. Anyway, that's a story for another day.

During the course of solving this problem, I came across a .NET utility I've not used previously: CORFLAGS.EXE. This utility essentially lets you force a .NET assembly (EXE or DLL) to execute as 32-bit or 64-bit.

In my case, all I needed to do was execute the following command on the target .NET EXE file:

CORFLAGS.EXE <target-exe> /32BIT+

where <target-exe> is the path to the .NET EXE to set the 32-bit flag on.

There are a number of other options the utility accepts.

You can find CORFLAGS.EXE in the Windows SDK, typically installed to eg %programfiles%\Microsoft SDKs\Windows\v7.0A\bin.

No comments:

Post a Comment