简体   繁体   English

参考.Net 4.5和netstandard2.0项目的.Net 4.5项目拉错了版本但是可以工作

[英].Net 4.5 Project with Reference to .Net 4.5 and netstandard2.0 Project pulls wrong version but works

I have a class library that I've ported from .Net 4.5 to a new multi-target class library targeting .Net 4.5 and netstandard2.0 . 我有一个类库,该类库已从.Net 4.5移植到一个新的针对.Net 4.5netstandard2.0多目标类库。 This all seems to work as expected. 这一切似乎都按预期工作。

However, my unit test library in the same solution is targeting .Net 4.5 . 但是,我在同一解决方案中的单元测试库的目标是.Net 4.5 When I look at the project reference, it seems to be pulling in the netstandard2.0 binary. 当我查看项目参考时,它似乎在netstandard2.0二进制文件。 When I run the unit tests, everything compiles and works as expected, however, it was my understanding that I'd need to be targeting at least .Net 4.6.1 for the project to successfully use a netstandard2.0 reference. 当我运行单元测试时,所有内容都可以按预期进行编译和运行,但是,据我了解,为了使该项目成功使用netstandard2.0参考,我需要至少针对.Net 4.6.1

What am I misunderstanding? 我有什么误会?

Quote from Microsoft Documentation Says Microsoft文档的报价说

The various .NET implementations target specific versions of .NET Standard. 各种.NET实现以.NET Standard的特定版本为目标。 Each .NET implementation version advertises the highest .NET Standard version it supports, a statement that means it also supports previous versions. 每个.NET实现版本都宣传其支持的最高.NET Standard版本,这表明它也支持以前的版本。 For example, the .NET Framework 4.6 implements .NET Standard 1.3, which means that it exposes all APIs defined in .NET Standard versions 1.0 through 1.3. 例如,.NET Framework 4.6实现.NET Standard 1.3,这意味着它公开了.NET Standard版本1.0至1.3中定义的所有API。 Similarly, the .NET Framework 4.6.1 implements .NET Standard 1.4, while .NET Core 1.0 implements .NET Standard 1.6. 同样,.NET Framework 4.6.1实现.NET Standard 1.4,而.NET Core 1.0实现.NET Standard 1.6。

Hope it helps 希望能帮助到你

Reference 参考

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

相关问题 无法将.Net Core 2.0项目的项目引用添加到Azure函数项目(netStandard2.0) - Not able to add project reference of .Net Core 2.0 project to Azure functions project(netStandard2.0) 将netstandard2.0库加载到net461项目 - Load in netstandard2.0 libraries to net461 project 当项目 .NET 6.0 引用子模块项目 .netstandard2.0 时,找不到 VS 2022 元数据文件“C:\*\crypto.dll” - VS 2022 Metadata file 'C:\*\crypto.dll' could not be found when a project .NET 6.0 reference a submodule project .netstandard2.0 如何将4.5版本的WCF项目升级到.NET 6 - How to upgrade 4.5 version WCF project to .NET 6 在.net 4.5项目中使用.net 2.0 dll(vshost在调试时崩溃) - use .net 2.0 dll in .net 4.5 project (vshost crashes on debug) Project MyAzureFunc与netstandard2.0>(.NETStandard,Version = v2.0)不兼容 - Project MyAzureFunc is not compatible with netstandard2.0 > (.NETStandard,Version=v2.0) 在.netStandard2.0项目中添加“连接服务” - Add “Connected service” in .netStandard2.0 project 如何在 .NetStandard2.0 项目中定位 Windows? - How to target Windows in .NetStandard2.0 project? 项目参考解决方案.net 4.5和.net 3.5 - Project reference work-around .net 4.5 and .net 3.5 为什么.net 4.0项目不能引用4.5程序集? - Why cant a .net 4.0 project reference a 4.5 assembly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM