这个问题应该从其标题中清楚地说明,但让我更详细地解释一下。我刚刚完成了我的应用程序的编写,我认为是.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,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
答案 0 :(得分:3)
当您创建面向.NET 4.0的新项目时,Visual Studio会自动添加对一些常用的.NET 4.0程序集的引用。但是,在查找目标平台时,这些引用不会被删除,因此需要手动删除,因为您无法从.NET 2.0应用程序引用.NET 4.0程序集。
首先删除这些错误的引用,然后查看是否还有错误。如果您使用了.NET 2.0中不可用的任何.NET功能,则可能需要更改某些源代码,或者如果缺少.NET 2.0程序集,则可能需要添加新的引用。
出现的任何编译器错误都可能指向正确的方向。
答案 1 :(得分:2)
是的,但您需要删除任何引用大于2的.net版本的代码。要清除上述错误,您需要删除对所有项目的引用,其中包含“引用的组件xx可能找不到“。此外,您还需要搜索资源,配置等文件,以替换任何.net 4引用.net 2 - >从4.0.0.0到2.0.0.0,或者如果它们在.net 2中不存在,则完全删除引用。
答案 2 :(得分:2)
错误消息告诉您错误,在这种情况下,您的项目中的引用无法解析。展开项目树中的references节点,并删除带有警告图标的引用。
如果您在此之后尝试编译,则可能会收到有关您使用的.NET 2.0中不可用的类,命名空间或关键字的其他错误。您必须删除它们或更改您的代码。
答案 3 :(得分:0)
由于Linq在.NET 2.0中不可用,您可以尝试LinqBridge作为替代。