在仅 .NET 4 的系统上运行 .NET 3.5 应用程序 [英] Running .NET 3.5 apps on .NET 4 only systems

查看:53
本文介绍了在仅 .NET 4 的系统上运行 .NET 3.5 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题之前可能已经被问过多次,但我无法找到适合我的典型解决方案.建议的解决方案是将其放在app.config"文件中:

<预><代码><配置><启动><supportedRuntime version="v4.0"/></启动></配置>

但是使用简单的Hello World"程序时,我仍然收到错误消息:无法找到运行此应用程序的运行时版本.".

对于某些背景,我使用的是 Windows XP(通过 Windows 7 上的 Windows Virtual PC),并且只在 XP 上安装了 .NET 4.0 运行时.

经过一番研究,我找到了这个页面:http://msdn.microsoft.com/en-us/library/ee941656.aspx#core

里面提到如果你的应用配置文件名为application-name.config,重命名为application-name.exe.config.例如,重命名MyApp.config为MyApp.exe.config."

我试过了,认为它可以解决问题,但我仍然收到无法找到运行此应用程序的运行时版本".当我尝试在带有 .NET 4.0 的 WinXP 上运行 .NET 3.5(客户端配置文件或完整版)应用程序时.

解决方案

我破解了.这听起来可能很愚蠢,但事实证明,配置文件需要与用户文件夹中的最终可执行文件一起存在.经过我所有的研究,这似乎没有在任何地方得到澄清.我认为它仅用于编译目的,位于开发人员的文件夹中.

在VS编辑器文件列表中,可以保留为app.config".但是,编译时,VS 会自动创建{ProgramName}.exe.config"(并将其放在 bin/release 文件夹中).这是需要与可执行文件一起放入最终用户文件夹的文件.

总而言之,是的,可以在仅安装 .NET 4.0 的系统上运行 .NET 3.5 应用程序.

This question has been asked before perhaps multiple times, but I can't get the typical solution to work for me. The proposed solution is to put this in the "app.config" file:

<configuration>
   <startup>
      <supportedRuntime version="v4.0"/>
   </startup>
</configuration>

But with a simple "Hello World" program, I still get the error: "Unable to find a version of the runtime to run this application.".

For some background, I'm using Windows XP (through Windows Virtual PC on Windows 7), and only installed the .NET 4.0 runtime on XP.

After some research, I found this page: http://msdn.microsoft.com/en-us/library/ee941656.aspx#core

It mentioned "If your application configuration file is named application-name.config, rename it to application-name.exe.config. For example, rename MyApp.config to MyApp.exe.config.".

I tried that, thinking it could solve the issue, but I still get "Unable to find a version of the runtime to run this application." when I try to run the .NET 3.5 (client profile or full) application on WinXP with .NET 4.0.

解决方案

I cracked it. This might sound daft, but it turns out that the config file needed to be with the final executable in the user's folder. After all my researching, this didn't appear to be clarified anywhere. I was thinking it was only used for compiling purposes to be in the developer's folder.

In the VS editor file list, it can remain as "app.config". However, when compiled, VS automatically creates "{ProgramName}.exe.config" instead (and puts it in the bin/release folder). This is the file that needs to go in the end user's folder along with the executable.

To summarize, yes, it is possible to run a .NET 3.5 app on a system which only has .NET 4.0 installed.

这篇关于在仅 .NET 4 的系统上运行 .NET 3.5 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆