When you compile a .NET program into an assembly and do not specify a CPU architecture, it will of course run on every architecture. It will also mean, that it will be run as a 32bit program on a 32bit OS (x86), and will be run as a 64bit program on a 64bit OS (x64).
Sometimes, you will want to force a .NET program to run as a 32bit application, even on a 64bit system. You might wonder, what on earth can make you do that. Well, here are two scenarios.
#1: The .NET program works on 32bit OS and crashes on 64bit
I have actually faced this scenario some while ago. As it turned out, the program did a p/invoke and that crashed on 64bit OSes. This was of course a bug on the part of the program, but I would not wait for the author to fix it. I needed to run the program as a 32bit application (on my 64bit OS), which would solve this issue.
#2: WinDbg will not handle stack frames in the call stack the same on 64bit and 32bit
This might or might not be a problem for you, and it might be solved in a later version of the Debugging Tools for Windows.
To solve these problems you can use corflags.exe. This is included with the .NET Framework SDK. It can run without the SDK, so you can copy&paste it onto the target machine if you have to. With this tool you can change a flag value in the CLR header that will instruct the CLR to ALWAYS run the given application in 32bit mode. Clearing this flag will of course always run in the native mode of the OS.
To force 32bit mode on an application, use:
corflags assembly /32bit+
To not force 32bit mode and run in the native mode of the OS, use:
corflags assembly /32bit-