1

I want to use Twitter in my app and i am using Twitter using Hammock Windows DLL,SO when i create the rest client like this

private void GetTwitterToken()
{
    var credentials = new OAuthCredentials
    {
        Type = OAuthType.RequestToken,
        SignatureMethod = OAuthSignatureMethod.HmacSha1,
        ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader,
        ConsumerKey = MyTwitter.ConsumerKey,
        ConsumerSecret = MyTwitter.ConsumerSecret,
        Version = MyTwitter.OAuthVersion,
        CallbackUrl = MyTwitter.CallbackUri
    };

    /*
    var client = new RestClient
    {
        Authority = "https://api.twitter.com/oauth",
        Credentials = credentials,
        HasElevatedPermissions = true
    };
    */

    var client = new RestClient
    {
        Authority = "https://api.twitter.com/oauth",
        Credentials = credentials,
        HasElevatedPermissions = true,
        SilverlightAcceptEncodingHeader = "gzip",
        DecompressionMethods = DecompressionMethods.GZip
    };

    var request = new RestRequest
    {
        Path = "/request_token"
    };
    client.BeginRequest(request, new RestCallback(TwitterRequestTokenCompleted));
}

private void TwitterRequestTokenCompleted(RestRequest request, RestResponse response, object userstate)
{
    Debug.WriteLine("Twitter Request Token Completed");

    _oAuthToken = GetQueryParameter(response.Content, "oauth_token");
    _oAuthTokenSecret = GetQueryParameter(response.Content, "oauth_token_secret");
    var authorizeUrl = MyTwitter.AuthorizeUri + "?oauth_token=" + _oAuthToken;

    if (String.IsNullOrEmpty(_oAuthToken) || String.IsNullOrEmpty(_oAuthTokenSecret))
    {
        Dispatcher.BeginInvoke(() => MessageBox.Show("error calling twitter"));
        return;
    }

    Dispatcher.BeginInvoke(() => browserControl.Navigate(new Uri(authorizeUrl)));
}

I am getting error as NullReferenceException-> Hammock.WindowsPhone.dll!

Hammock.Silverlight.Compat.GzipHttpWebResponse.GetResponseStream() + 0x1c bytes

and in the stack, I am getting the error as

at Hammock.Silverlight.Compat.GzipHttpWebResponse.GetResponseStream()

at Hammock.Web.WebQuery.GetAsyncResponseCallback(IAsyncResult asyncResult)

at System.Net.Browser.ClientHttpWebRequest.<>c_DisplayClassa.<InvokeGetResponseCallback>b_8(Object state2)

at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state)

at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

at System.Threading.ThreadPool.WorkItem.doWork(Object o)

at System.Threading.Timer.ring()

What could be the problem?

Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166
Rakesh
  • 14,997
  • 13
  • 42
  • 62
  • 2
    Well the exception isn't in the code you've *given*... please show the full stack trace of the exception, and where it occurs in your code. – Jon Skeet May 22 '12 at 10:42
  • at Hammock.Silverlight.Compat.GzipHttpWebResponse.GetResponseStream() at Hammock.Web.WebQuery.GetAsyncResponseCallback(IAsyncResult asyncResult) at System.Net.Browser.ClientHttpWebRequest.<>c__DisplayClassa.b__8 (Object state2) at System.Threading.ThreadPool.WorkItem.WaitCallback_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring() – Rakesh May 22 '12 at 10:58
  • 1
    Please edit that into your question, along with your code *using* the API. This may well just be a bug in Hammock of course. – Jon Skeet May 22 '12 at 10:59
  • Well you still haven't shown your code using the API... – Jon Skeet May 22 '12 at 11:06
  • No, but if you could come up with a short but *complete* program - ideally as a console app, if you can - it'll make it easier to diagnose. – Jon Skeet May 23 '12 at 07:30
  • sorry for wierd way of asking jon. – Rakesh May 23 '12 at 08:50

1 Answers1

0

There was reference problem,that was causing the problem,it was fixed,Thanks for your support jon

Rakesh
  • 14,997
  • 13
  • 42
  • 62
  • I am also facing a similar problem. Please tell me, What was the fix? – nkchandra May 28 '12 at 12:12
  • Problem was that it was referring to some old Hammock .dll file in debug,Once i removed and made a clean reference,there was no issue after that – Rakesh May 28 '12 at 12:46