Newtonsoft.json 程序集包版本不匹配

时间:2023-04-26
本文介绍了Newtonsoft.json 程序集包版本不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我正在尝试使用 SocketIO4Net 在 .net 中创建 socket.io 客户端.看来 SocketIO4Net 具有 Newtonsoft.Json >= 4.0.8 的依赖项.我也在使用 PushSharp 库,它的 Newtonsoft.Json 依赖项 >= 4.5.10.当我第一次安装 PushSharp 时,我得到了 NewtonSoft.Json 4.5.11,我认为这个版本也应该支持 SocketIO4Net,因为它的版本更高,但是每当我尝试连接到 socket.io 服务器时都会出现这个错误.

I am trying to use SocketIO4Net to create socket.io client in .net. Itseems SocketIO4Net has a dependency of Newtonsoft.Json >= 4.0.8. I also am using PushSharp library which has a Newtonsoft.Json dependency of >= 4.5.10. I got NewtonSoft.Json 4.5.11 when i first installed PushSharp and I thought this version should support SocketIO4Net as well since its a higher version but i get this error whenever am trying to connect to socket.io server.

无法加载文件或程序集Newtonsoft.Json, Version=4.0.8.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"或其依赖项之一.找到的程序集的清单定义与程序集引用不匹配.(HRESULT 异常:0x80131040)

Could not load file or assembly 'Newtonsoft.Json, Version=4.0.8.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

我整天都在为这些依赖问题头疼,如果有人能指出我正确的方向,我将不胜感激.

I have been banging my head all day with these dependency issues, I would be very grateful if someone can point me in the right direction.

推荐答案

找到解决办法,试试:

<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>

这篇关于Newtonsoft.json 程序集包版本不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:Newtonsoft Json.Net 序列化 JObject 不会忽略空值,即使设置正确 下一篇:Newtonsoft Json 将字典反序列化为来自 DataContractJsonSerializer 的键/值列表

相关文章