3

I have a .Net application, written in C#. The application has been compiled with the "any" flag, allowing it to run as both 64 and 32 bits, depending on the OS that it's deployed on.

I'm wondering if it's possible to force the application to run as a 32 bit application, on a 64 bit version of windows (any 64 bit version of windows).

2 Answers 2

4

Yup, use CorFlags to set the 32BIT flag on the executable. E.g:

corflags.exe myapp.exe /32BIT+

This will modify your exe, so you might wanna keep a backup just in case. You can also revert the flag using /32BIT- instead of /32BIT+

1
  • Good answer! However, using Corflags requires to change the exe, or at least to make a copy, that can be problematic in certain environments. Here I found a solution how to start a program using a simple command line wrapper which avoids this.)
    – Doc Brown
    Feb 6 at 16:55
0

Newer information:

When a .NET application is built inside Visual Studio 2012 and up, the default setting is AnyCPU with an additional sub-type of AnyCPU, “Any CPU 32-bit preferred”. It implies the following:

  • If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
  • If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
  • If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code.

Source: http://blogs.microsoft.co.il/sasha/2012/04/04/what-anycpu-really-means-as-of-net-45-and-visual-studio-11/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .