Rahul Shirphule
Rahul Shirphule

Reputation: 999

.exe is not a valid Win32 application on Windows XP

I'm using Visual Studio 2012 Professional and creating an installer by using Advanced installer (3rd party).

When I run the installed .exe on Windows XP, I get the following message:

<appName>.exe is not a valid Win32 application.

The installed executable works fine on both Windows 7 and 8.

How can I get the program to work on Windows XP?

Upvotes: 11

Views: 34849

Answers (3)

Muhammad Faizan Khan
Muhammad Faizan Khan

Reputation: 10551

Actually .NET 4.5 framework generates only Window 6.0 or greater version compatible EXE. And in your case XP belong to windows version 5.0 therofre, you are getting this error. T

The simple solution is to your problem is, target .NET 4.0 or less.

Thanks to Hans Passant

Upvotes: 0

sjsam
sjsam

Reputation: 21965

I am quite new to Visual Studio so I am not sure if the below option is added recently but Visual Studio 2013 has a backward compatibility option to incorporate Win_XP in target list. The below image helps :

Visual Studio Configuration


And then when I run the dumpbin command, I got the below results.

enter image description here


So now the application, under normal circumstances, can be run in Windows XP.
Hope this is helpful.

Upvotes: 1

Hans Passant
Hans Passant

Reputation: 941337

From the Visual Studio Command Prompt, run this command:

 Dumpbin.exe /headers c:\where\you\put\it\setup.exe

Where "setup.exe" is the setup EXE created by your installer creator. I'll post an example of the info you see that matters here:

OPTIONAL HEADER VALUES
             10B magic # (PE32)
            ...
            4.00 operating system version
            0.00 image version
            6.00 subsystem version              // <=== here!!
               0 Win32 version
            ...

The subsystem version number is important. VS2012 is the first version of Visual Studio that started setting this value to 6.00, the version number of Vista. Previous versions, as well as VS2012 when you target .NET 4.0 or earlier, will set this version number to 4.00

This is otherwise an important move ahead and part of phasing out support for XP. Windows version 6.00 and up, Vista, Win7 and Win8 pay attention to this number. They'll assume that your program is unaware of later Windows features and needs to have several appcompat shims turned on. The most notable one is appcompat in Aero, the desktop theme that displays windows with fat borders that are easy to click with a mouse. Windows will lie about those borders, telling you that your window is smaller than it actually is. A great source of confusion to programmers that try to make windows line up with each other.

The consequence of seeing 6.00 displayed is that your setup program cannot run on XP anymore. It is version 5.02.

So do make sure first that you do not target .NET version 4.5, it is not available for XP. Use 4.0 instead. If you still have trouble then contact the vendor's support and ask them how to control that number in the setup.exe file that the tool creates. A workaround is to run Editbin.exe with the /SUBSYSTEM option to change the number.

Upvotes: 17

Related Questions