加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 使用.net 4.0编写的程序,但我需要此应用程序在运行.net 2.

发布时间:2020-12-16 01:47:24 所属栏目:百科 来源:网络整理
导读:这个问题应该从其标题中清楚地说明,但让我更详细地解释一下.我刚刚完成了我的应用程序的编写,我认为是.Net 4.0框架(见下图).在意识到我需要我的应用程序与最早版本的.Net框架兼容之后,我回过头来改变了Visual Studio的Properties窗口中的Target Framework.不
这个问题应该从其标题中清楚地说明,但让我更详细地解释一下.我刚刚完成了我的应用程序的编写,我认为是.Net 4.0框架(见下图).在意识到我需要我的应用程序与最早版本的.Net框架兼容之后,我回过头来改变了Visual Studio的Properties窗口中的Target Framework.不幸的是,这样做给我留下了一长串警告 – 以及一个严重的错误.我很好奇是否有人有一些解决方案可以让我的应用程序(使用.Net 4.0框架编写)在运行.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,either remove the reference "System.Xml.Linq" or retarget your application to a framework version which contains "System.Core,PublicKeyToken=b77a5c561934e089".   Protection
Warning 5   The primary reference "System.Data.DataSetExtensions",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,either remove the reference "System.Data.DataSetExtensions" or retarget your application to a framework version which contains "System.Core,PublicKeyToken=b77a5c561934e089".   Protection
Warning 1   The primary reference "System.Core",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",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,PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. Line 123,position 5.    C:UsersFARINA_EVANDocumentsProgrammingC#Run Time CrypterRun Time CrypterPropertiesResources.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程序集,则可能需要添加新的引用.

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读