Can a WinForms app compiled for "Any CPU" be configured to run as "x86" on a 64-bit server without recompiling the app? Specifically, I'm looking for an app.config setting or Control Panel applet to accomplish this end. All the customer's clients are x86, but the server is x64, and we like to install the WinForms app on the server for administrators to configure and monitor the system. We would much rather not recompile just for the server.
From http://www.request-response.com/blog/PermaLink,guid,34966ef8-3142-46b2-84e0-372b5c36ddcc.aspx
You can, however, control and override this default behaviour even after your code has been compiled. There's a handy tool called corflags.exe present in the SDK that allows you to force 'anycpu' compiled code to use 32-bit process in 64-bit world.
The usage of this utility is found here http://msdn.microsoft.com/en-us/library/ms164699(VS.80).aspx
No configuration ought to be needed if you wrote your managed code correctly. As long as the 64-bit machine has the proper frameworks installed, the JIT process will take care of any of the differences between 32 and 64 bit requirements.
The only thing you need to be concerned about in your own code is if you were doing any P/Invoke. In that case, any time you call an API function that utilizes a HANDLE or void* type, you need to ensure that you always use System.IntPtr, and not System.Int32. In the .NET world, the int data type is ALWAYS 32 bits, even on a 64 bit machine. Likewise a long is always 64 bits, no matter what architecture.
And IntPtr however is always the size of void*, and so properly JIT's to different sizes depending on the architecture of the machine you're running on.
I found this link helpful too: http://blogs.intesoft.net/2007/12/default.aspx