代码改变世界

未能加载文件或程序集 Newtonsoft.Json, Version=4.5.0.0

2015-06-16 16:08  jdilt  阅读(593)  评论(0编辑  收藏  举报

使用httpclient测试webapi的时候客户端报错:

问题是由于System.Net.Http.Formatting和Json.NET版本冲突,在app.config里对Json.NET的版本重定向一下就好了。

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </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-6.0.0.0" newVersion="6.0.0.0"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>