简体   繁体   English

从.net库引用.NET Standard 1.6库

[英]Reference a .NET Standard 1.6 library from a .net library

I'm trying to use a library in my application, I'm kinda new to this I'm following this instructions, https://docs.microsoft.com/en-us/dotnet/core/tutorials/consuming-library-with-visual-studio?tabs=csharp 我正在尝试在我的应用程序中使用一个库,对此我还是有点陌生​​,我正在按照以下说明进行操作: https://docs.microsoft.com/zh-cn/dotnet/core/tutorials/using-library- with-visual-studio?tabs = csharp

where basically I've opened the library solution and added a new project to it, however when I run I get the following error: 基本上,我在哪里打开了图书馆解决方案并向其中添加了一个新项目,但是当我运行时,出现以下错误:

Project '..\\src\\gdax.netcore.csproj' targets 'netstandard1.6'. 项目'.. \\ src \\ gdax.netcore.csproj'目标为'netstandard1.6'。 It cannot be referenced by a project that targets '.NETFramework,Version=v4.5'. 面向“ .NETFramework,Version = v4.5”的项目无法引用该文件。 GdApp1 GdApp1

I'm not sure how to fix this, I've tried changing various target versions in both the library and my project, if I set my project target to 4.6.1 I get missing directives or assembly references, related to the library I'm using. 我不确定如何解决此问题,我尝试更改库和项目中的各种目标版本,如果我将项目目标设置为4.6.1,则会丢失与库相关的指令或程序集引用。米使用。

I'm trying to use this library https://github.com/sefbkn/gdax.netcore my code is basically a straight copy of their example at this point 我正在尝试使用此库https://github.com/sefbkn/gdax.netcore我的代码目前基本上是其示例的直接副本

the missing references and errors are: 缺少的参考和错误是:

The type or namespace name 'RequestAuthenticator' could not be found (are you missing a using directive or an assembly reference?)  

The type or namespace name 'ProductClient' could not be found (are you missing a using directive or an assembly reference?) 

The type or namespace name 'gdax' could not be found (are you missing a using directive or an assembly reference?)  

The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'.    

There are multiple steps here 这里有多个步骤

  1. Check you are using a recent version of VS (suggested 15.5.* for .NET 4.7.1+netstandard support) 检查您使用的是VS的最新版本(建议使用15.5。* for .NET 4.7.1 + netstandard支持)
  2. Target at least .NET 4.6.1 to reference netstandard1.6 libraries 至少将.NET 4.6.1定位为引用netstandard1.6库
  3. Follow https://github.com/dotnet/announcements/issues/31 to resolve library loading issues. 请遵循https://github.com/dotnet/announcements/issues/31解决库加载问题。 This involves enabling automated binding redirect generation for the application using it and modifying the csproj for unit tests. 这涉及为使用它的应用程序启用自动绑定重定向生成,并修改csproj以进行单元测试。

Alternatively, wait for .NET 4.7.2 and Visual Studio 2017 version 15.6 to remove the need for manual steps. 或者,等待.NET 4.7.2和Visual Studio 2017 15.6版以消除手动步骤的需要。

You also need to NETStandard.Library nuget package to your project that tries to use any .Net Standard dll. 您还需要将NETStandard.Library nuget包添加到尝试使用任何.Net Standard dll的项目中。

https://www.nuget.org/packages/NETStandard.Library/ https://www.nuget.org/packages/NETStandard.Library/

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

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