首页 > 解决方案 > 更改 TargetingFramework 后无法加载文件或程序集...

问题描述

我刚刚将 .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我尝试在文件夹Newtonsoft.Json

因此,如何在更改目标框架后正确添加所有这些 .dll?

标签: c#visual-studioframeworksnuget.net-standard

解决方案


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

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


推荐阅读