开发者

Error when updating Twitter status with Twitterizer

I have this test application, for twitterizer.

var temp = TwitterViewModel.TokenStore;

       string token = HttpContext.Current.Request.QueryString["oauth_token"];
       string verifier = HttpContext.Current.Request.QueryString["oauth_verifier"];
       string ConsumerKey = WebConfigurationManager.AppSettings["twitterApiKey"];
       string ConsumerSecret = WebConfigurationManager.AppSettings["twitterConsumerSecret"];

       OAuthTokenResponse TwitterResponse = OAuthUtility.GetAccessToken(ConsumerKey, ConsumerSecret, token, verifier);

       var Tokens = new OAuthTokens();

       foreach (KeyValuePair<string, OAuthTokens> Token in TwitterViewModel.TokenStore)
           if (Token.Key == UserSession.GetSession().Login)
               Tokens = Token.Value;

       if (TwitterResponse != null)
       {
           Tokens.AccessToken = TwitterResponse.Token;
           Tokens.AccessTokenSecret = TwitterResponse.TokenSecret;
       }

       TwitterViewModel.TokenStore.Remove(UserSession.GetSession().Login);

       TwitterResponse<TwitterStatus> Response = TwitterStatus.Update(Tokens, "testmsg");

       ResponseErrorMessage = Response.ErrorMessage;
       ResponseResult = Response.Result.ToString();
       ResponseContent = Response.Content;

And seems to be working, until it reaches this line: "TwitterResponse Response = TwitterStatus.Update(Tokens, "testmsg");" The tweet is put on the twitter "wall" and I got back an error message: "Could not load file or assembly 'Newtonsoft.Json, Version=3.5.0.0... ". I checked my packages, and I have a newtonsoft.json 4.0.1. If its possible I dont really want to degrade that newtonsoft package from 4.0 to 3.5.

If anybody has any idea how could I solve this problem, that开发者_如何转开发 would be great! Cheers.


You can either

  1. add a <bindingRedirect> to your app.config to specify Twitterizer should use the new version instead (assuming the API has not changed)

  2. get the Twitterizer source and rebuild it yourself against Json 4.0.1.


For option 1. supplied by Rup, I updated web.config with the following:

...

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

   </runtime>
</configuration>

And it fixed the issue.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜