【问题标题】:Could not load file or assembly 'Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'无法加载文件或程序集“Newtonsoft.Json,版本=8.0.0.0,文化=中性,PublicKeyToken=30ad4fe6b2a6aeed”
【发布时间】:2016-03-31 09:28:01
【问题描述】:

我从 nuget 包安装了Newtonsoft.Json

但我遇到了错误

无法加载文件或程序集“Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed”或其依赖项之一。系统找不到指定的文件。

您能告诉我这背后的原因是什么以及如何解决吗?

【问题讨论】:

  • “系统找不到指定的文件”:还不够清楚吗?
  • 在哪里找到文件?我已经检查了引用的路径,并且那里存在 dll
  • dll和可执行文件在同一个文件夹吗?这通常是它应该在的地方
  • 是在同一个文件夹中:(我需要在 GAC 中进行更改吗?

标签: c# json


【解决方案1】:

检查Package.config,你有8.0版本

    <package id="Newtonsoft.Json" version="8.0.2" targetFramework="net45" />

尝试在 web.config 中添加以下内容

<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0"/>
  </dependentAssembly>

另外,如果您在项目位置有任何旧版本的 dll,请将其删除

【讨论】:

    【解决方案2】:

    这是一个老问题。但是每当我将新项目添加到我的旧应用程序时,我都会收到此错误。以下是我解决问题的方法:

    1. 更新项目文件(c# 的 .csproj)并将以下内容添加到包含 Configuration、Platform、ProjectGuid 属性的第一个属性组:
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
    <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
    
    1. 移除绑定重定向

    2. 升级到最新的newrelic包

    这一直对我有用

    【讨论】:

      猜你喜欢
      • 2017-11-15
      • 2014-04-25
      • 1970-01-01
      • 2016-11-07
      • 2016-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多