Assembly looking for wrong version of Newtonsoft.Json.dll

安稳与你 提交于 2019-12-11 06:26:27

问题


My project is using Newtonsoft.Json.dll. I have added the dll as a reference to my project and im using version 8.0.2

Everything works on my pc however when i transfer everything to a new pc along with Newtonsoft.Json.dll i get the error

Could not load file or assembly 'Newtonsoft.Json‚ Version=4.0.3.0‚ Culture=neutral‚ PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

Im not referencing that version anywhere and there is nothing in my app.config specifying this.


回答1:


The previous answer will help you to track down the problem. It happens when some referenced library explicitly specified a version of library that it supports. Fortunately, you can override binding in app.config (see example below):

<configuration>
  <!--YOUR 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>
    </assemblyBinding>
  </runtime>
</configuration>



回答2:


I would check the version of Newtonsoft.Json in the bin directory of the start up project. If Newtonsoft.Json is there and it is the version you are expecting, then you can use Fuslogvw (https://msdn.microsoft.com/en-us/library/e74a18c4(v=vs.110).aspx) to see where the loader is trying to get the 4.0.3.0 version from. That might give you some insight into why the runtime is looking for a different version.

Hope that helps.



来源:https://stackoverflow.com/questions/40979337/assembly-looking-for-wrong-version-of-newtonsoft-json-dll

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!