[英]Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0?
I have an issue in Newtonsoft.json library.我在 Newtonsoft.json 库中遇到问题。 When i try to run project using visual studio, it's working properly.
当我尝试使用 Visual Studio 运行项目时,它工作正常。 But when i tried to create .exe on this, it shows a run time error
但是当我尝试在此创建 .exe 时,它显示了一个运行时错误
Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0,
Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependancies.
The system cannot find the file specified.
In refereence and bin folder newsoft.json file available.在参考和 bin 文件夹中的 newsoft.json 文件可用。 Also in package folder also available.
同样在包文件夹中也可用。 Why this error triggers only when i create .exe?
为什么此错误仅在我创建 .exe 时触发? Please help me..
请帮我..
.NET projects are not normally run as a standalone *.exe file. .NET 项目通常不会作为独立的 *.exe 文件运行。
You're choice is either create a setup project for your program or to copy the whole bin\\Release
folder.您可以选择为您的程序创建安装项目或复制整个
bin\\Release
文件夹。 This folder should contain all the necessary non-standard libraries (the standard .NET libraries are provided by the operating system).此文件夹应包含所有必需的非标准库(标准 .NET 库由操作系统提供)。
I had the same problem, but my project was a console application made with .Net full, referencing another .Net standard project which had the NewntonSoft referenced.我遇到了同样的问题,但我的项目是一个使用 .Net full 制作的控制台应用程序,引用了另一个引用了 NewntonSoft 的 .Net 标准项目。 Both projects needs to use package management the same way.
两个项目都需要以相同的方式使用包管理。 This article explains this better:
这篇文章更好地解释了这一点:
https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx https://www.hanselman.com/blog/ReferencingNETStandardAssembliesFromBothNETCoreAndNETFramework.aspx
尝试通过升级来匹配所有子项目上的包版本。
Installed Costura.Fody library file.安装 Costura.Fody 库文件。 Now its working as expected.
现在它按预期工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.