[WP7] NotImplementedException in UpdateStatus

Jun 28, 2012 at 3:41 AM
Edited Jun 28, 2012 at 3:44 AM

Hi,

I'm trying to use UpdateStatus in a WP7 application and shortly after the method returns, I get a NotImplementedException from within LinqToTwitterWP.

This is how I'm using it:

var status = _context.UpdateStatus(tweet, true);

Whenever I use that, the tweet appears in the account perfectly fine and the Status object seems to be fine, but not long after the exception is thrown. (I actually pop up a messagebox and it only triggers after that closes)

A try/catch doesn't catch the exception. This itself is running on a thread but this still occurs if I run it on the UI thread.

Here is the call stack if that helps:

>	LinqToTwitterWP.dll!Ionic.Zlib.GZipStream.Length.get() + 0x5 bytes	
 	mscorlib.dll!System.IO.StreamReader.ReadToEnd() + 0x28 bytes	
 	LinqToTwitterWP.dll!LinqToTwitter.TwitterExecute.GetTwitterResponse(System.Net.WebResponse resp) + 0x45 bytes	
 	LinqToTwitterWP.dll!LinqToTwitter.TwitterExecute.ExecuteTwitter.AnonymousMethod__37(System.IAsyncResult ar) + 0x2e bytes	
 	System.Windows.dll!System.Net.Browser.ClientHttpWebRequest.InvokeGetResponseCallback.AnonymousMethod__8(object state2) + 0x1b bytes	
 	mscorlib.dll!System.Threading.ThreadPool.WorkItem.WaitCallback_Context(object state) + 0x18 bytes	
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x63 bytes	
 	mscorlib.dll!System.Threading.ThreadPool.WorkItem.doWork(object o) + 0x47 bytes	
 	mscorlib.dll!System.Threading.Timer.ring() + 0x70 bytes	

Any help would be greatly appreciated as it seems I cannot even trap the exception and hide it.

Thanks,
Michael

Coordinator
Jun 28, 2012 at 4:32 AM

Hi Michael,

There's a demo in the downloadable source code in a folder named WindowsPhoneDemo with an example you can use.  I noticed that you're using a synchronous overload, which shouldn't work. Instead, you should use only the Async overloads in WP.  Here's an example:

                twitterCtx.UpdateStatus(TweetTextBox.Text,
                    updateResp => Dispatcher.BeginInvoke(() =>
                    {
                        switch (updateResp.Status)
                        {
                            case TwitterErrorStatus.Success:
                                Status tweet = updateResp.State;
                                User user = tweet.User;
                                UserIdentifier id = user.Identifier;
                                MessageBox.Show(
                                    "User: " + id.ScreenName +
                                    ", Posted Status: " + tweet.Text,
                                    "Update Successfully Posted.",
                                    MessageBoxButton.OK);
                                break;
                            case TwitterErrorStatus.TwitterApiError:
                            case TwitterErrorStatus.RequestProcessingException:
                                MessageBox.Show(
                                    updateResp.Error.ToString(),
                                    updateResp.Message,
                                    MessageBoxButton.OK);
                                break;
                        }
                    }));

Joe

 

Jun 28, 2012 at 4:44 AM
Edited Jun 28, 2012 at 4:44 AM

Hi Joe,

Thanks for the reply. I still get this error even with your posted code. For reference I'm using the Nuget package with WP 7.1.

With the async code: (NotImplementedException)

 

>	LinqToTwitterWP.dll!Ionic.Zlib.GZipStream.Length.get() + 0x5 bytes	
 	mscorlib.dll!System.IO.StreamReader.ReadToEnd() + 0x28 bytes	
 	LinqToTwitterWP.dll!LinqToTwitter.TwitterExecute.GetTwitterResponse(System.Net.WebResponse resp) + 0x45 bytes	
 	LinqToTwitterWP.dll!LinqToTwitter.TwitterExecute.ExecuteTwitter.AnonymousMethod__37(System.IAsyncResult ar) + 0x2e bytes	
 	System.Windows.dll!System.Net.Browser.ClientHttpWebRequest.InvokeGetResponseCallback.AnonymousMethod__8(object state2) + 0x1b bytes	
 	mscorlib.dll!System.Threading.ThreadPool.WorkItem.WaitCallback_Context(object state) + 0x18 bytes	
 	mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x63 bytes	
 	mscorlib.dll!System.Threading.ThreadPool.WorkItem.doWork(object o) + 0x47 bytes	
 	mscorlib.dll!System.Threading.Timer.ring() + 0x70 bytes	

Michael

Coordinator
Jun 28, 2012 at 5:31 AM

I see where the problem is happening, but I don't know how to reproduce it on my system.  The best I can do right now is guess and here are a few questions that might help:

  1. Did you run the sample with the downloadable source code? 
  2. Are you authenticating okay? 
  3. My culture is en-US - is yours the same.
  4. Does the response from Twitter appear to be gzipped? (I read the HTTP response in Fiddler2). To go down that path, I would expect the Content-Encoding in the response to have 'gzip' and the response be garbled (even after decryption).
  5. I'm wondering if the debug version of LinqToTwitterWP.dll might provide more info?

Joe

Jun 28, 2012 at 6:49 AM

I just ran it with the sample in the downloadable source and that seems to work fine, no exceptions there. The emulator has been set to en-US for the entire time (same instance) and Windows is on en-AU.

Authentication seems to be fine, I can post the tweets and they appear in the timeline if I check in the browser, but this seems to be failing when trying to check the length of the GZipped stream on line 319 of TwitterExecute. The Content-Encoding is set to gzip in the response.

I copied the same compiled version over to my app to see if that would help (also in debug mode) but that did not help. When using the async overload it throws the exception before the callback, and the Status object returned in the TwitterResponse<> is correct as far as I can see - all of the tweet details are there.

Coordinator
Jun 28, 2012 at 10:40 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Jun 29, 2012 at 4:36 AM

Thanks for the feedback on this bug.  I kept trying different things and the problem finally reproduced (though I don't know why).  However, as soon as it happened, I was able to fix the problem. This is checked in now and you can get the latest source code and build the LinqToTwitterWP project.

Joe