How do I target .NET 4.0.3 on XP using Visual Stud

2019-01-22 19:54发布

I have a large application targeting .NET 4.0.3 that needs to run on XP. It builds fine using Visual Studio 2010 SP1 and runs properly on XP.

Building using Visual Studio 2012 targeting .NET 4.0.3 also builds fine and runs fine on Windows 7 but it fails to run on XP. I get an error saying MyApp.exe is not a valid Win32 application.

How do I continue to target .NET 4.0.3 with support for XP machines using Visual Studio 2012?

6条回答
萌系小妹纸
2楼-- · 2019-01-22 20:13

I'm not certain this will work, but try the trick shown here to manually set the subsystem version with EditBin.exe.

查看更多
等我变得足够好
3楼-- · 2019-01-22 20:13

We are also having this problem. It isn't a matter of what framework your application is targeting (we are targetting the 4.0 client).

The problem is that Visual Studio 2012 will not produce a click once setup.exe that will run on XP. The error is missleading as it always reports that the program is not a valid Win32 application. It does this on any version of XP including 64-bit versions.

It is not your application causing the problem, it is the setup.exe produced by VS2012. The only way we have found to get around it is to publish using VS2010.

查看更多
祖国的老花朵
4楼-- · 2019-01-22 20:14

Microsoft just recently posted a fix for this. (Express versions included.)

Details at: http://blogs.msdn.com/b/smondal/archive/2012/10/15/setup-exe-is-not-a-valid-win32-application.aspx

查看更多
老娘就宠你
5楼-- · 2019-01-22 20:14

It's possible to set the target system requirements under the Project Properties -> Publish -> Prerequisites panel (VS2012 with Update 1). Even though you're building for .NET 4 (Project Properties -> Application -> Target Framework) you'll need to change the prerequisites from 4.5 to 4 as it wont drop the requirements automatically.

Building with a target of 4 but prereq of 4.5 will start the installer but fail on system checks

查看更多
姐就是有狂的资本
6楼-- · 2019-01-22 20:20

This worked for me - just build your solution in Studio 2012, and take a copy of the contents of the solution from the Debug folder. Make sure XP client has .net 4 installed.

查看更多
你好瞎i
7楼-- · 2019-01-22 20:26

VS2012 Update 1 is supposed to resolve this issue. However, I am not sure what options to use though, is it Toolset under Project Properties->General->Platform Toolset?

查看更多
登录 后发表回答