简体   繁体   English

无法在Windows XP上运行Visual Studio 2012程序

[英]Can't run Visual Studio 2012 program on Windows XP

I have a simple C# console application built using Visual Studio 2012 and .NET 4.5. 我有一个使用Visual Studio 2012和.NET 4.5构建的简单C#控制台应用程序。

When I build the solution on my 64 bit Windows 7 machine and then copy the MyProgram.exe file from this location: 当我在64位Windows 7计算机上构建解决方案,然后从此位置复制MyProgram.exe文件时:

C:\\Users\\me\\Desktop\\MyProgram\\MyProgram\\bin\\x86 C:\\用户\\我\\桌面\\ MyProgram \\ MyProgram \\ BIN \\ X86

to a Windows XP machine, and then try to run the MyProgram.exe file, I get the following error: 到Windows XP机器,然后尝试运行MyProgram.exe文件,我收到以下错误:

MyProgram.exe is not a valid win32 application

I can see by just Googling the problem that lots of other people have the same issue and there are many suggested solutions. 我只能谷歌搜索问题,许多其他人有同样的问题,并有许多建议的解决方案。 But none of the solutions seem to help me. 但是这些解决方案似乎都没有帮助我。

Can someone please give me step-by-step instructions for how to prepare the .exe file to run on XP? 有人可以给我一步说明如何准备.exe文件在XP上运行吗?

The steps I used (without creating a new project): 我使用的步骤(没有创建新项目):

  1. Open the project settings, choose Application. 打开项目设置,选择“应用程序”。
  2. On "Target framework", choose .Net Framework 4. 在“目标框架”上,选择.Net Framework 4。
  3. Recompile 重新编译

That's it. 而已。

Remember to also set the Publish (one-click) setting under "Prerequisites" to use Framework 4, if you're using the publish feature. 如果您正在使用发布功能,请记住还要将“先决条件”下的“发布(一键)”设置设置为使用框架4。 I found the client version of the framework doesn't seem to cut it, you need the full version despite what the documentation seems to indicate, but maybe that's on a project-by-project basis. 我发现框架的客户端版本似乎没有削减它,你需要完整版本,尽管文档似乎表明,但也许这是在逐个项目的基础上。

I finally got it to work!! 我终于开始工作!! All this time trying to figure out how to fix the problem and the solution was having to recreate the entire project from scratch. 这一直试图弄清楚如何解决问题,解决方案是必须从头开始重新创建整个项目。

For anyone is this same situation, save yourself the time and headache and do the following: 对于任何人都是同样的情况,节省时间和头痛,并做以下事情:

  1. Save and close all instances of VS2012. 保存并关闭VS2012的所有实例。
  2. Start a completely new instance of VS, and target .NET 4.0. 启动一个全新的VS实例,并以.NET 4.0为目标。
  3. Before doing anything else , go into the configuration manager and target x86. 在执行任何其他操作之前 ,请进入配置管理器并定位x86。
  4. Now copy your old code into this project. 现在将旧代码复制到此项目中。
  5. Compile and run on XP. 编译并在XP上运行。
  6. Done! 完成!

Programs compiled in Windows Vista and later cannot be run in Windows XP. 在Windows Vista及更高版本中编译的程序无法在Windows XP中运行。

http://blogs.msdn.com/b/vcblog/archive/2012/06/15/10320645.aspx

You need to set the compiler to VC2010, and make sure you compile in 'release' mode to make sure the program can be run in another machine. 您需要将编译器设置为VC2010,并确保在“释放”模式下编译以确保程序可以在另一台机器上运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在Windows XP下运行Lightswitch 2012 Programm - Can't run Lightswitch 2012 Programm under Windows XP 使用Visual Studio 2012创建的C#Windows窗体应用程序无法在Windows XP上运行 - C# Windows forms app created using Visual Studio 2012 not working on windows xp 运行Windows XP SP2中的Visual Studio 2010中内置的Windows应用程序 - Run Windows Application built in Visual Studio 2010 in Windows XP SP2 exe 无法在 windows xp 上运行甚至将 .net 更改为 4.0 - exe can't run on windows xp even change .net to 4.0 Visual Studio 2013:适用于Windows XP的Build - Visual Studio 2013: Build for Windows XP Visual Studio 2012可以并行运行单元测试吗? - Can Visual Studio 2012 run unit tests in parallel? 如何使用 Visual Studio 2012 在 XP 上定位 .NET 4.0.3? 应用程序无法运行,“不是有效的 Win32 应用程序” - How do I target .NET 4.0.3 on XP using Visual Studio 2012? Application fails to run with “not a valid Win32 application” 为什么在未安装Visual Studio的计算机中无法运行.NET程序的调试版本 - Why can't I run debug version of .NET program in the machine didn't install visual studio 无法在Visual Studio 2012 Ultimate上安装SSH.NET - Can't install SSH.NET on Visual Studio 2012 Ultimate 无法在Visual Studio 2012中打开.NET 4.0.1目标项目 - Can't open .NET 4.0.1 targeted project in Visual studio 2012
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM