Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

vb.net - .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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

From the Visual Studio Command Prompt, run this command:

 Dumpbin.exe /headers c:whereyouputitsetup.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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...