Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用.NET4.0编写的程序,但我需要此应用程序在运行.NET2.0的计算机上运行_C#_.net_Winforms - Fatal编程技术网

C# 使用.NET4.0编写的程序,但我需要此应用程序在运行.NET2.0的计算机上运行

C# 使用.NET4.0编写的程序,但我需要此应用程序在运行.NET2.0的计算机上运行,c#,.net,winforms,C#,.net,Winforms,这个问题单从标题就应该很清楚,但让我更详细地解释一下。我刚刚完成了应用程序的编写,我相信是在.NET4.0框架中完成的(见下图)。在意识到我需要我的应用程序与最早版本的.Net framework兼容后,我返回并在Visual Studio的“属性”窗口中更改了目标框架。不幸的是,这样做给我留下了一长串令人痛苦的警告——还有一个严重的错误。我很好奇,是否有人有办法让我的应用程序(使用.NET4.0框架编写)在运行.NET2.0框架的环境中运行 原编 错误列表: 非常感谢。 埃文 编辑: 我知

这个问题单从标题就应该很清楚,但让我更详细地解释一下。我刚刚完成了应用程序的编写,我相信是在.NET4.0框架中完成的(见下图)。在意识到我需要我的应用程序与最早版本的.Net framework兼容后,我返回并在Visual Studio的“属性”窗口中更改了目标框架。不幸的是,这样做给我留下了一长串令人痛苦的警告——还有一个严重的错误。我很好奇,是否有人有办法让我的应用程序(使用.NET4.0框架编写)在运行.NET2.0框架的环境中运行

原编

错误列表: 非常感谢。 埃文

编辑: 我知道第二张图片对我们大多数人来说并不完全可见,因此我将在下面发布错误:

Warning 9   The referenced component 'System.Xml.Linq' could not be found.  
Warning 10  The referenced component 'System.Data.DataSetExtensions' could not be found.    
Warning 8   The referenced component 'System.Core' could not be found.  
Warning 11  The referenced component 'Microsoft.CSharp' could not be found.     
Warning 4   The primary reference "System.Xml.Linq", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Xml.Linq" or retarget your application to a framework version which contains "System.Xml.Linq".   Protection
Warning 2   The primary reference "System.Xml.Linq" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Xml.Linq" or retarget your application to a framework version which contains "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".   Protection
Warning 5   The primary reference "System.Data.DataSetExtensions", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Data.DataSetExtensions" or retarget your application to a framework version which contains "System.Data.DataSetExtensions". Protection
Warning 3   The primary reference "System.Data.DataSetExtensions" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Data.DataSetExtensions" or retarget your application to a framework version which contains "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".   Protection
Warning 1   The primary reference "System.Core", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "System.Core" or retarget your application to a framework version which contains "System.Core".   Protection
Warning 6   The primary reference "Microsoft.CSharp", which is a framework assembly, could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "Microsoft.CSharp" or retarget your application to a framework version which contains "Microsoft.CSharp".    Protection
Error   7   Could not load file or assembly 'System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Line 123, position 5.    C:\Users\FARINA_EVAN\Documents\Programming\C#\Run Time Crypter\Run Time Crypter\Properties\Resources.resx   123 5   Protection

可以,但您需要删除引用.net版本大于2的任何代码。要清除上述错误,您需要删除对所有项目的引用,其中显示“找不到引用的组件xx”。此外,您还需要搜索资源、配置等文件,以将.net 4对.net 2->的任何引用从4.0.0.0替换为2.0.0.0,或者如果这些引用在.net 2中不存在,则完全删除它们。

错误消息会告诉您出了什么问题,在这种情况下,您的项目中存在无法解决的引用。展开项目树中的“引用”节点,并删除带有警告图标的引用


如果在此之后尝试编译,则可能会遇到其他有关所使用的类、名称空间或关键字的错误,这些错误在.NET2.0中不可用。您必须删除这些文件或更改代码。

由于Linq在.NET 2.0中不可用,您可以尝试替换它。

当您创建一个针对.NET 4.0的新项目时,Visual Studio会自动添加对一些常用的:NET 4.0程序集的引用。但是,更改目标平台时,不会删除这些引用,因此需要手动删除,因为您无法从.NET 2.0应用程序中引用.NET 4.0程序集

因此,从删除这些错误的引用开始,看看是否还有错误。如果使用了.NET 2.0中不可用的任何.NET功能,则可能需要更改某些源代码,或者如果缺少.NET 2.0程序集,则可能需要添加对它们的新引用


出现的任何编译器错误都可能为您指明正确的方向。

重新编码以排除任何4.0特定功能。唉,我认为这里没有捷径。如果你右键单击并选择“查看图像”,图像实际上是非常可见的。那么,当我重新添加时,Visual Studio会自动查找每个dll的.net 2.0版本吗?@Evan:有些dll没有.net 2.0等效版本。恕我直言,我知道有什么问题。我不知道解决这个问题的最佳方法。我不想把我的申请表搞砸。。