vb.net .exe 不是 Windows XP 上的有效 Win32 应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16455855/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
.exe is not a valid Win32 application on Windows XP
提问by Rahul Shirphule
I'm using Visual Studio 2012 Professional and creating an installer by using Advanced installer (3rd party).
我正在使用 Visual Studio 2012 Professional 并使用高级安装程序(第 3 方)创建安装程序。
When I run the installed .exe on Windows XP, I get the following message:
当我在 Windows XP 上运行已安装的 .exe 时,我收到以下消息:
<appName>.exe is not a valid Win32 application.
<appName>.exe 不是有效的 Win32 应用程序。
The installed executable works fine on both Windows 7 and 8.
安装的可执行文件在 Windows 7 和 8 上都可以正常工作。
How can I get the program to work on Windows XP?
如何让程序在 Windows XP 上运行?
回答by Hans Passant
From the Visual Studio Command Prompt, run this command:
从 Visual Studio 命令提示符运行以下命令:
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:
其中“setup.exe”是安装程序创建者创建的安装程序 EXE。我将在此处发布您看到的重要信息示例:
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
子系统版本号很重要。VS2012 是第一个开始将此值设置为 6.00(Vista 的版本号)的 Visual Studio 版本。以前的版本以及面向 .NET 4.0 或更早版本的 VS2012 都会将此版本号设置为 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.
否则,这是一项重要的举措,也是逐步取消对 XP 支持的一部分。Windows 6.00 及以上版本,Vista、Win7 和 Win8 会注意这个数字。他们会假设您的程序不知道以后的 Windows 功能,并且需要打开多个 appcompat 垫片。最引人注目的是 Aero 中的 appcompat,这是一种桌面主题,它显示带有易于用鼠标单击的粗边框的窗口。Windows 会在这些边界周围撒谎,告诉您您的窗口比实际小。对于试图使窗口彼此对齐的程序员来说,这是一个很大的困惑来源。
The consequence of seeing 6.00 displayed is that your setup program cannot run on XP anymore. It is version 5.02.
看到 6.00 显示的结果是您的安装程序不能再在 XP 上运行。它是 5.02 版。
So do make sure first that you do nottarget .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.
因此,请首先确保您的目标不是.NET 版本 4.5,它不适用于 XP。请改用 4.0。如果您仍然遇到问题,请联系供应商的支持并询问他们如何控制该工具创建的 setup.exe 文件中的该数字。解决方法是运行带有 /SUBSYSTEM 选项的 Editbin.exe 以更改编号。
回答by sjsam
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 很陌生,所以我不确定最近是否添加了以下选项,但 Visual Studio 2013 具有向后兼容性选项,可将 Win_XP 合并到目标列表中。下图有帮助:
And then when I run the dumpbin
command, I got the below results.
然后当我运行dumpbin
命令时,我得到了以下结果。
So now the application, under normal circumstances, can be run in Windows XP.
Hope this is helpful.
所以现在该应用程序,在正常情况下,可以在Windows XP 中运行。
希望这是有帮助的。
回答by Muhammad Faizan Khan
Actually .NET 4.5 framework generates only Window 6.0 or greater version compatibleEXE. And in your case XP belong to windows version 5.0therofre, you are getting this error. T
实际上 .NET 4.5 框架只生成与Window 6.0 或更高版本兼容的EXE。在您的情况下,XP 属于 Windows 5.0therofre,您会收到此错误。吨
The simple solution is to your problem is, target .NET 4.0 or less.
解决您的问题的简单方法是,针对 .NET 4.0 或更低版本。