Newtonsoft.Json大会冲突 [英] Newtonsoft.Json Assembly Conflict

查看:206
本文介绍了Newtonsoft.Json大会冲突的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用Netonsoft.Json在我的项目。直到我开始在我的项目整合贝宝SDK它工作正常。我的code是如下图所示。

I use Netonsoft.Json in my project. It works fine until I start integrating Paypal SDK in my Project. My code is as below.

         String AccessToken =
  new PayPal.OAuthTokenCredential("", "").GetAccessToken(); ---->>>> This Line Throwing An Error
            PayPal.Api.Payments.Address add = new PayPal.Api.Payments.Address();
            add.city = TextBoxCity.Text;
            add.line1 = TextBoxAddress.Text;
            add.phone = TextBoxPhoneNumber.Text;
            add.postal_code = TextBoxZipcode.Text;
            add.state = TextBoxState.Text;
            PayPal.Api.Payments.CreditCard cc = new PayPal.Api.Payments.CreditCard();
            cc.number = TextBoxCreditCardNumber.Text;
            cc.first_name = TextBoxFirstName.Text;
            cc.last_name = TextBoxLastName.Text;
            cc.expire_month = Convert.ToInt16(TextBoxExpiryMonth.Text);
            cc.expire_year = Convert.ToInt16(TextBoxExpiryYear.Text);
            cc.cvv2 = TextBoxCVVNumber.Text;
            cc.billing_address = add;
            cc.Create(AccessToken);

和我得到如下错误

       System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=4.5.0.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 search on internet and found some solution to change config file. SO I change my config file as below

        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
     <bindingRedirect oldVersion="0.0.0.0-3.5.0.0" newVersion="4.5.0.0" />
  </dependentAssembly>
</assemblyBinding>

我也玩arroung像复制本地,特定版本装配性能,但没有帮助我解决这个问题。如何解决冲突组装?

I also play arroung with assembly properties like Copy Local, Specific Version but nothing helps me to solve this. How Can I solve assembly conflict?

推荐答案

我只是有同样的问题,我用更新Newtonsoft.Json到最新版本解决了这个问题。

I just had the same problem and I solved it by updating the Newtonsoft.Json to the latest version using

Update-Package Newtonsoft.Json

然后将Web.config文件并添加:

and then going to Web.config and adding:

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed"/>
    <bindingRedirect oldVersion="0.0.0.0-4.5.0.0" newVersion="5.0.8"/>
</dependentAssembly>

这篇关于Newtonsoft.Json大会冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆