繁体   English   中英

使用.net 4.0编写的程序,但我需要此应用程序在运行.net 2.0的计算机上运行

[英]Program written using .net 4.0 but I need this application to run on computers running .net 2.0

这个问题应该从其标题中清楚地说明,但让我更详细地解释一下。 我刚刚完成了我的应用程序的编写,我认为是.Net 4.0框架(见下图)。 在意识到我需要我的应用程序与最早版本的.Net框架兼容之后,我回过头来改变了Visual Studio的Properties窗口中的Target Framework。 不幸的是,这样做给我留下了一长串警告 - 以及一个严重的错误。 我很好奇是否有人有一些解决方案可以让我的应用程序(使用.Net 4.0框架编写)在运行.Net 2.0框架的环境中运行。

原始编译

在.Net 4.0 Framework中编译的证明

错误列表:

.Net 2.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 4.0的新项目时,Visual Studio会自动添加对一些常用的.NET 4.0程序集的引用。 但是,在查找目标平台时,这些引用不会被删除,因此需要手动删除,因为您无法从.NET 2.0应用程序引用.NET 4.0程序集。

所以首先删除这些错误的引用,看看是否还有错误。 如果您使用了.NET 2.0中不可用的任何.NET功能,则可能需要更改某些源代码,或者如果缺少.NET 2.0程序集,则可能需要添加新的引用。

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

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

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

如果您在此之后尝试编译,则可能会收到有关您使用的.NET 2.0中不可用的类,命名空间或关键字的其他错误。 您必须删除它们或更改您的代码。

由于Linq在.NET 2.0中不可用,因此您可以尝试使用LinqBridge作为替代品。

暂无
暂无

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

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