Run applications in Windows 7 as 32 bit

10,957

Solution 1

This is an unfortunate trap in VS2010, the "Active solution platform" setting in Configuration Manager is not relevant for managed C# and VB.NET projects. For C#, you have to use Project + Properties, Build tab, Platform target setting. Only the setting on the startup (EXE) project matters.

Solution 2

You want the corflags tool in the SDK

corflags MyApp.exe /32bit+

will change the exe to run as a 32bit process.

Conversely

corflags MyApp.exe /32bit-

Will change the exe to be AnyCPU

corflags MyApp.exe

Will tell you what's in the header for the exe, so you can actually see what it's going to target.

Share:
10,957
slandau
Author by

slandau

Updated on June 04, 2022

Comments

  • slandau
    slandau almost 2 years

    So we have an app that used to compile to "Any CPU". It would run in 64 bit mode on Windows 7 machines, but would error out when it tried to make a call to an interop running in 32 bit mode.

    I went through and changed the compile targets to target x86 for the project, compiled and ran it locally, and it worked fine.

    However, when this change was committed, it still runs as 64 bit in Windows 7 machines in production.

    When I made the change, I just opened the Configuration Manager in VS2010, changed it to x86, saved it, and committed the change for each project in the solution.

    How can I get it to run in 32 bit mode? Do I need to change something else?