简体   繁体   中英

Project X targets '.NETStandard,Version=v1.6'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'

I really wanted to be a good citizen... copied all my classes to .net standard 1.6 libraries. Just to find out that my test DLL can't use it. I get the following error

Project X targets '.NETStandard,Version=v1.6'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.6.1'.

Of course, when I check .Net Standard ( https://docs.microsoft.com/en-us/dotnet/articles/standard/library ) it says that with 1.6 it can target 4.6.1 .

I tried 4.6.2 without better luck. I installed the .net standard 1.6.1 NuGet package. Anyway, you guys are awesome, I'm sure you'll tell me which stupid mistake I'm making that is preventing me from doing something as basic as running unit tests with a .net standard library.

Thanks


PS I did find a work around (kind of) by using a .net core unit test project instead of a .net framework one. It doesn't solve my problem, so I can't mark that as an answer, but at least I can go back to coding...

You need to upgrade to .Net Core SDK 2.x+

Once that is installed restart your machine and you should be able to reference NetStandard 1.6 in .Net Framework 4.6.1+

With .Net Core SDK 1.x you can only reference Net Standard 1.5 in .Net Framework 4.6.2

Best would be to upgrade your Net Standard project to version 2.0 if you can.

如果针对不同版本的.net框架的类似标题出现错误,这通常意味着您需要(如果已经没有安装)将项目目标更改为.net框架的新版本/最新版本以符合针对较新的.net标准的项目。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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