JahManCan
JahManCan

Reputation: 601

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.

Upvotes: 2

Views: 2099

Answers (2)

Eric P
Eric P

Reputation: 2977

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.

Upvotes: 1

Rup
Rup

Reputation: 34408

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.

Upvotes: 5

Related Questions