【问题标题】:.NET Standard Nuget References.NET 标准 Nuget 参考
【发布时间】:2017-05-08 22:28:43
【问题描述】:

我正在用 .NET Standard 制作一个类库,我希望它可以在 Windows 和 Android 上使用。但是,当我尝试直接引用项目或项目输出时,我会在运行时得到AssemblyNotFoundExceptions,而我的 .NET Standard 项目引用的每个 NuGet 包都有一个不同的包。将每个 NuGet 包添加到每个引用 .NET Standard 项目的项目中,这个问题就消失了,但感觉像是一个不可持续的解决方案。 解决 .NET Standard 项目中的依赖关系的最佳方法是什么?我使用的是 Visual Studio 2017,我的控制台项目是 .NET 4.7,我的 .NET Standard 项目是 .NET Standard 1.6。

我已经从我的控制台项目中引用了 NETStandard.Library,但它不起作用。 System.ValueTuple 等类型在我尝试使用时仍然会抛出异常。

现在,我在尝试运行我的程序时遇到的异常是:

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.'

这是有道理的,因为我在 .NET Standard 库中使用序列化。

【问题讨论】:

  • 可能需要在 app.config 文件中添加必要的程序集重定向。请发布您遇到的确切例外情况。
  • @LexLi 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.'
  • bin 文件夹中的实际程序集可能是 4.3.0.0。检查并了解如何重定向。
  • 你是引用输出dll目录还是使用项目引用?
  • @MartinUllrich 我都试过了,都没有。

标签: c# .net .net-standard .net-4.7


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-09-18
    • 2020-05-14
    • 1970-01-01
    • 1970-01-01
    • 2019-03-21
    • 1970-01-01
    • 2018-05-21
    • 2016-10-31
    相关资源
    最近更新 更多