我有一个netstandard2.0项目,用于与第三方Web服务进行交互.在相同的解决方案中,我需要从一个较旧的 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项目?
发布评论