简体   繁体   English

在.Net 4.0程序中运行.Net 2.0可执行文件

[英]Running .Net 2.0 executable in .Net 4.0 program

I'm trying to run an external executable from my program. 我正在尝试从程序中运行外部可执行文件。 My program is compiled on the .Net 4.0 framework in order to enable it to run on Windows XP. 我的程序在.Net 4.0框架上进行编译,以使其能够在Windows XP上运行。 The external application is compiled on the .Net 2.0 framework. 外部应用程序是在.Net 2.0框架上编译的。 When I run this program on my machine (Windows 7, .Net 4.5 installed) it works fine, however when I run it in XP with .Net 4.0 installed I get the following error: Unable to find a version of the runtime to run this application. 当我在计算机上运行该程序(安装Windows 7,.Net 4.5)时,它运行良好,但是当我在安装了.Net 4.0的XP中运行该程序时,出现以下错误: Unable to find a version of the runtime to run this application. I tried modifying the app.config file as follows, but with no luck: 我尝试按如下方式修改app.config文件,但没有运气:

<?xml version="1.0"?>
<configuration>
<startup> 
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
    <supportedRuntime version="v2.0" sku=".NETFramework,Version=v2.0"/>
</startup>
</configuration>

Is there any other way to get around this problem? 还有其他方法可以解决此问题吗?

In general, you should not uninstall any versions of the .NET Framework that are installed on your computer, because an application you use may depend on a specific version and may break if that version is removed. 通常,您不应卸载计算机上安装的.NET Framework的任何版本,因为您使用的应用程序可能取决于特定版本,并且如果删除该版本,则可能会中断。 You can load multiple versions of the .NET Framework on a single computer at the same time. 您可以在一台计算机上同时加载多个版本的.NET Framework。 This means that you can install the .NET Framework without having uninstall previous versions. 这意味着您可以在不卸载早期版本的情况下安装.NET Framework。 For more information, see Getting Started with the .NET Framework. 有关更多信息,请参见.NET Framework入门。 http://msdn.microsoft.com/en-us/library/bb822049.aspx http://msdn.microsoft.com/en-us/library/bb822049.aspx

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM