以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [分享]Newtonsoft.Json多个版本引用  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=161772)

--  作者:ajie5211
--  发布时间:2021/3/29 9:32:00
--  [分享]Newtonsoft.Json多个版本引用

在遇金蝶k3cloud对接的过程中,出现了Newtonsoft.Json引用报错,原因是金蝶用的版本较旧(4.0.0.0),狐表用的较新(12.0.2.23222).折腾多日,遇版主交流,一直未能解决,本想全用狐表的JSON搞算了,但又发现金蝶有些接口,接口文档没有给出服务器地址,始终不可实现全部功能。最后又回到了引用金蝶官方dll的路上,现把处理方式分享如下:报错信息


图片点击可在新窗口打开查看此主题相关图片如下:1.png
图片点击可在新窗口打开查看

注意看圈出来的信息,然后去金蝶Kingdee\\K3Cloud\\WebSite\\Bin目录下复制Newtonsoft.Json.dll文件到自己电脑,改名为Newtonsoft.Json.j4.dll,复制到狐表安装目录下,修改狐狸安装目录下的Foxtable.exe.config文件,增加下面红色的部分,其中publicKeyToken的值和version的值要与报错的值一样。

 <dependentAssembly>
        <assemblyIdentity name="C1.C1Excel.4"
          publicKeyToken="79882d576c6336da"
          culture="neutral" />
        <bindingRedirect oldVersion="4.0.20191.359" newVersion="4.0.20183.338" />
      </dependentAssembly>
       <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json"
          publicKeyToken=""
          culture="neutral" />
         <codeBase version="4.0.0.0" href="Newtonsoft.Json.j4.dll" />
        <bindingRedirect oldVersion="4.0.0.0-12.0.0.0" newVersion="12.0.2.23222" />
      </dependentAssembly>

    </assemblyBinding>
    <AppContextSwitchOverrides value="Switch.UseLegacyAccessibilityFeatures=false;Switch.UseLegacyAccessibilityFeatures.2=false;Switch.UseLegacyAccessibilityFeatures.3=false" />
  </runtime>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>


--  作者:ajie5211
--  发布时间:2021/3/29 9:50:00
--  

测试结果如下


图片点击可在新窗口打开查看此主题相关图片如下:2.png
图片点击可在新窗口打开查看