c# - System.IO.FileNotFoundException:'无法加载文件或程序集'Newtonsoft.Json,版本 = 12.0.0.0,
问题描述
这是我得到的错误:
System.IO.FileNotFoundException:'无法加载文件或程序集'Newtonsoft.Json,版本 = 12.0.0.0,文化 = 中性,PublicKeyToken = 30ad4fe6b2a6aeed'。该系统找不到指定的文件。'
这就是我在cs项目中的内容:
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath> </Reference>
路径似乎是正确的。
我试图找到不同的解决方案,例如将软件包重新安装到早期版本并将 app.config 修改为此:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
没有任何效果。
解决方案
就我而言,我已经通过 Nuget 包安装了 V 12.0.0.3,我得到了同样的错误。根据我自己的经验。一些 NewtonSoft版本对 Visual Studio 的某些版本感到愤怒。
如果您只需要简单的反序列化和序列化功能,如果您从解决方案重新安装 Newtonsoft 当前软件包并安装版本6.0.3 ,您的问题将得到解决
此版本与 Visual Studio 不同版本非常兼容。
推荐阅读
- javascript - 在 Node.js 中使用 Multer 的语法问题
- reactjs - 如何修复 d3.forceLink 上的“错误:缺失:0”
- javascript - React hooks 警告我缺少依赖项
- php - 对 Instagram 内容的 file_get_contents() 调用响应时间很长(超过 10 秒)
- unity3d - 光线投射点不在平面图层上(奇怪的位置)?
- apache-spark - Spark SQL 嵌套 JSON 错误“输入时没有可行的替代方案”
- email - 如何确保预定的电子邮件无法发送(SendGrid)?
- flutter - 如何使用 Flutter 跳转到移动设置
- python - 在 python 中查找二维列表的索引,其中包含另一个特定的子列表
- jsmodeler - 在 JSModeler 中围绕它们的中心旋转一组对象