C# 绑定将json.net从6.0.0重定向到4.5.5
我正在使用.net开发一个API 对于这个项目,我还需要使用log4net和gelf4net WebAPI使用Newtonsoft.json V4.5.0.0 gelf4net使用Newtonsoft 6.0.0 然后我从nugget更新了Newtonsoft,但我得到一个异常,即Newtonsoft.json 4.5.0.0无法加载,这是我更新后的正常情况 我做了一些调查,看到了那件事。我试过一个,但不幸的是我没有找到如何使它工作 这是:C# 绑定将json.net从6.0.0重定向到4.5.5,c#,.net,api,json.net,assembly-binding-redirect,C#,.net,Api,Json.net,Assembly Binding Redirect,我正在使用.net开发一个API 对于这个项目,我还需要使用log4net和gelf4net WebAPI使用Newtonsoft.json V4.5.0.0 gelf4net使用Newtonsoft 6.0.0 然后我从nugget更新了Newtonsoft,但我得到一个异常,即Newtonsoft.json 4.5.0.0无法加载,这是我更新后的正常情况 我做了一些调查,看到了那件事。我试过一个,但不幸的是我没有找到如何使它工作 这是: <runtime> <assembl
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<codeBase version="4.5.0.0" href="bin\json.net\Newtonsoft.Json.dll" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="6.0.0.0"/>
<codeBase version="6.0.0.0" href="bin\Newtonsoft.Json.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
我将旧版本放在bin的子文件夹中,并将a href放在config中。。
还是有例外
我在微软的网站上看到了这个
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="myAssembly"
publicKeyToken="32ab4ba45e0a69a1"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0"
newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我只是不明白,因为不可能添加两次相同的程序集(甚至是不同的版本),所以第二个应该放在哪里?
编辑:
还尝试使用一个简单的:
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
<bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="6.0.0"/>
您有什么建议/解决方案需要测试吗?
非常感谢。
将。视为一种解决方法:
- 我在Github上下载了Gelf4net源代码
- 将json.net dll替换为5.0.0
- 重新编译
- 已将新dll添加到我的项目中