Thursday, April 28, 2022

Building a 32 bit application on 64 bit window

Life is not that easy as it seems particularly if you are developer.  I hope all of the developers reading this will agree with me. I have windows 10 system having visual studio 2017. I have to compile a C# GUI application that can run on 32 bit windows specifically that can run on a windows XP. Does not that sound very easy? You can do this by just setting the build configuration as shown in the below image then build  the application. Seems like a cake walk, is not it?



I did the same thing and compile the application and copy the application on windows XP machine to run on the application.  But it did not run on that particular machine I had copied to. I could not understand what could be the issue. Every time I tried to run the application it throws an error “ Not a valid win32 application”. I searched  a lot on Google. People advised to compile it for x86 rather than x64. Since I had already compiled that for 32 bit it should not be a problem in my case.  Though I tried to implement their suggestion it did not worked for me. Some suggest to check the “.NET target framework” for xp. Since I am not using any framework this option also ruled out. Lastly after a lot of effort someone suggested me to check  platform toolset and set it to XP as shown in the below picture.



Remember platform toolset must be set to  “Visual Studio 2017 -Window XP(V141_xp). If you don’t have the toolset then please download and install it from Microsoft site. After making the changes I am able to run my application on windows XP machine. Hope this helps some developers while they compile their application for targeting Windows XP or similar OS.

Below is the list of sites that helped me solve the issue and I think it is my moral obligation to mention their name.

Reference Site :

1. https://social.msdn.microsoft.com/Forums/vstudio/en-US/990fb1a1-3940-421b-ab13-7ddcde5c00d5/exe-is-not-a-valid-win32-application?forum=vcgeneral

2.  https://social.msdn.microsoft.com/Forums/vstudio/en-US/47ef555b-99fb-411c-9a13-099b094884d5/not-a-valid-win32-application?forum=vbgeneral

3. https://social.msdn.microsoft.com/Forums/en-US/f699eb18-4090-479c-a2ac-a3c68bc46549/vs-2017-build-x86-for-2003-r2-exe-is-not-a-valid-win32-application?forum=vcgeneral


No comments:

Post a Comment