最近在玩推特的SDK,引用了[CoreTweet][1]的库。 在运行tokens.Statuses.Update方法的时候,报错提示:
无法加载文件或程序集'Newtonsoft.Json,Version = 9.0.0.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'
研究后发现,我虽然项目中已经引用了Newtonsoft.Json包,但是版本跟CoreTweet中的不一样。
知道这个就好解决了,因为我是WinForm程序,所以修改app.config即可。
在app.config的configuration节点中增加:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json"
publicKeyToken="30AD4FE6B2A6AEED" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="12.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
其中newVersion使用你的Newtonsoft.Json版本号。
参考: [未能加载文件或程序集“Newtonsoft.Json, Version=4.5.0.0"][2] [1]:https://github.com/CoreTweet/CoreTweet [2]:https://blog.csdn.net/mzl87/article/details/52353787

