无法从固件 4.8 控制台应用程序加载文件或程序集“netstandard”

问题描述 投票:0回答:1

我有一个针对 .NET Framework 4.8 的旧控制台应用程序。它加载一些 Nuget,它们都支持 .NET Standard 2.0 和 2.1。控制台应用程序构建得很好,但在加载第一个 Nuget DLL 时出现此运行时错误:

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' ---> System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'

因此,从兼容性角度来看,Framework 4.8 应该可以与 .NET Standard 2.0 兼容。运行时无法加载 netstandard 2.0 或 2.1 有充分的理由吗?

.net-4.8 .net-standard-2.0 .net-standard-2.1
1个回答
0
投票

.Netstandard 2.1 需要 .NET 5.0+。 .NET Framework 4.8 不支持它。看起来您正在尝试加载仅针对 netstandard 2.1 的程序集(也许您的 nuget 之一不支持 2.0,或者当它有多个目标时,由于某种原因选择了错误的目标)。

© www.soinside.com 2019 - 2024. All rights reserved.