c# - 在 4.0 项目中引用 .net Framework 4.5.1 程序集

标签 c# .net

如何使 4.0 项目具有 4.5 引用。在单元测试中,我无法构建解决方案,它给了我这个警告。

Warning 2 The primary reference "PR.Wallet" could not be resolved because it was built against the ".NETFramework,Version=v4.5.1" framework. This is a higher version than the currently targeted framework ".NETFramework,Version=v4.0". PR.Wallet.Tests

最佳答案

.Net 框架(v2.0 或更高版本) 不是 forward compatible . .您不能在 .Net 4.0 项目中引用 .Net 4.5 程序集。

参见:Version Compatibility in the .NET Framework

您还可以看到:Version Compatibility

The degree of .NET Framework support for backward and forward compatibility is version-specific. The .NET Framework supports both backward and forward compatibility for applications created using version 1.1 only. It does not support forward compatibility in applications created using version 2.0. In the context of the .NET Framework, backward compatibility means that an application created using an early version of the .NET Framework will run on a later version. Conversely, forward compatibility means that an application created using a later version of the .NET Framework will run on an earlier version.

The .NET Framework provides a high degree of support for backward compatibility. For example, most applications created using version 1.0 will run on version 1.1 and applications using version 1.1 will run on version 2.0. The .NET Framework also supports forward compatibility for version 1.1 only. However, for forward compatibility you might need to modify an application so that the application runs as expected. Applications created with version 2.0 will not run on earlier versions of the .NET Framework. For both backward and forward compatibility, a change to the .NET Framework that helps improve security, correctness, or functionality might also raise compatibility issues.

关于c# - 在 4.0 项目中引用 .net Framework 4.5.1 程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23807351/

相关文章:

c# - .net 4.5 框架中用于图像编辑的命名空间

c# - 让工具提示按我想要的方式运行的最简单方法是什么

.net - 创建互斥体会引发 DirectoryNotFoundException

c# - 捕获通用的非致命异常

c# - 获取AD OU列表

c# - 如何从 IGrouping 中删除元素

c# - .NET 3.5 : anonymous delegate for handlers with ref params

c# - NAudio播放IEEEFloat格式

c# - 使用Elasticsearch 7.1的NEST 7.0 alpha 2中的SortField

hash - 如何在c#中实现pbkdf2_sha256