简体   繁体   English

.NET标准Nuget参考

[英].NET Standard Nuget References

I am making a class library in .NET Standard, which I wish to be usable from Windows and Android. 我正在.NET Standard中创建一个类库,我希望它可以在Windows和Android中使用。 However, when I try to reference the project or the project output directly, then I get AssemblyNotFoundException s at runtime, with a different one for each NuGet package that my .NET Standard project references. 但是,当我尝试直接引用项目或项目输出时,我在运行时获得AssemblyNotFoundException ,而我的.NET Standard项目引用的每个NuGet包都有一个不同的。 Adding each NuGet package to every project that references the .NET Standard project makes this problem go away, but it feels like an unsustainable solution. 将每个NuGet包添加到引用.NET Standard项目的每个项目都会使这个问题消失,但这感觉就像一个不可持续的解决方案。 What is the best way to resolve the dependencies in a .NET Standard project? 解决.NET Standard项目中的依赖项的最佳方法是什么? I am using Visual Studio 2017, my console project is .NET 4.7, and my .NET Standard project is .NET Standard 1.6. 我使用的是Visual Studio 2017,我的控制台项目是.NET 4.7,我的.NET Standard项目是.NET Standard 1.6。

I have already referenced NETStandard.Library from my console project, but it does not work. 我已经从我的控制台项目中引用了NETStandard.Library,但它不起作用。 Type such as System.ValueTuple still throw exceptions when I attempt to use them. 当我尝试使用它们时,类型如System.ValueTuple仍会抛出异常。

Right now, the exception I am getting upon attempting to run my program is this: 现在,我试图运行我的程序时遇到的异常是这样的:

System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Runtime.Serialization.Formatters, Version=4.0.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'

Which makes sense, as I use serialization in my .NET Standard library. 这是有道理的,因为我在.NET标准库中使用序列化。

您是否尝试将.Net Standard 1.4用于您引用的库?

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

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