How to make programs work on Windows XP in Visual Studio 2012

Posted: Wednesday 27 February 2013

Programs compiled by Microsoft Visual Studio does not work in Windows XP by default, typically you'll encounter a error somewhere along the lines of  "<PROGRAM_PATH>.. is not a valid Win32 application".

Microsoft apparently has a hotfix to patch this error, but that is not the reason why your application doesn't work.
By default, your application is set up to run with the v4.5 release of the .net framework, which has an incompatible bootstrap to Windows XP - and as a result programs compiled with the 4.5 .net framework will not work with Windows XP.
So the fix is as follows:
Make sure that you backup your project first!
Access the properties of your application, you can do this by right clicking your project in the solution explorer and selecting "properties"

Then click on the list under "target framework"

Selecting the .net framework 4 or lower (note that your programs will not work if you're using .net 4.5 specific features but most of the time this will work)
Press "Yes" on the dialogue that follows
Recompile the program, and it should work with Windows XP!