我有一个 netstandard2.0 项目,我用它来与 3rd 方网络服务交互.我需要在同一个解决方案中从较旧的 4.6.2 项目中引用该项目,但是当我这样做时,我会收到一堆关于需要引用我定义的类型的错误.
I have a netstandard2.0 project that I'm using to interface with a 3rd party web service. I need to reference that project from an older 4.6.2 project in the same solution, but when I do I get a bunch of errors about needing references to types that I have defined.
例如,我将调用 netstandard 库中返回 Task 的方法,但我会收到一条错误消息,提示我需要对 System.Threading.Tasks 的引用,即使我已经有了.
For example, I'll call a method in the netstandard library that returns Task, but I'll get an error saying I need a reference to System.Threading.Tasks even though I already have one.
推荐答案我认为这里有两个问题.
I believe there are two issues here.
只有某些版本的 standard 可以与某些版本的 4.X.Y 配合使用
要解决此问题,您可能需要更改一个或两个项目的版本.使用图表确定哪些版本可以一起兼容:docs.microsoft/en-us/dotnet/standard/net-standard
To resolve this you may need to change the version of one or both projects. Use the chart to figure out which versions are compatible together: docs.microsoft/en-us/dotnet/standard/net-standard
4.X.Y 使用 4.0.0.0 系统库,而 standardX.Y 使用 4.3.0.0
要解决此问题,您需要添加并引用 netstandard.library NuGet 包.
To resolve this you need to add and reference the netstandard.library NuGet package.
更多推荐
你如何在VS2017中从.net项目中引用一个netstandard项目?
发布评论