【问题标题】:Could not load file or assembly ... after changing the TargetingFramework更改 TargetingFramework 后无法加载文件或程序集
【发布时间】:2021-07-01 04:39:45
【问题描述】:

我刚刚将 .csproj 从 <TargetFramework>netcoreapp3.1</TargetFramework> 更改为 <TargetFramework>netstandard2.0</TargetFramework> 并且在调试时收到以下信息:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly '..., Version=1.0.0.0, 
Culture=neutral, PublicKeyToken=null' or one of its dependencies. 
The system cannot find the file specified. at CDMToJSON.Program.Main(String[] args)

我尝试在文件夹 (Sources\CDMToJSON\bin\Debug\netstandard2.0) 中添加所有缺少的 .dll,但对于带有 Newtonsoft.Json 的错误一直存在,这让我认为有更好的方法来添加这些 NuGet 和依赖项。

因此,如何在更改 Targeting Framework 后正确添加所有这些 .dll?

【问题讨论】:

    标签: c# visual-studio frameworks nuget .net-standard


    【解决方案1】:

    netstandard TFM 仅适用于图书馆。它们不能用于可直接执行的项目,例如桌面应用程序、控制台应用程序或单元测试项目。

    您需要选择您的程序将要定位的具体运行时,例如netcoreapp3.1net5.0,然后定位它。

    【讨论】:

      猜你喜欢
      • 2015-01-20
      • 2016-03-04
      • 1970-01-01
      • 2020-08-17
      相关资源
      最近更新 更多