Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3789844
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:13:19+00:00 2026-05-19T12:13:19+00:00

I wrote a very simple C# application to send Tweets between to Windows machines.

  • 0

I wrote a very simple C# application to send Tweets between to Windows machines. To do this, each endpoint (ie this C#.NET desktop app that uses the TweetSharp library) has a timer, and when the Elapsed event fires all messages are gathered together with a GetDirectMessages() call, then these messages are parsed and processed by the endpoint.

My problem is that I built this over the course of a few hours two weeks ago and everything worked fine. I dusted it off and executed a week ago as well, no problems. Now, I break it out today and I am getting a very odd exception (see section EXCEPTION) that originate at the line “IEnumerable directMessage = service.ListDirectMessagesReceived();” (see section SOURCE). My question is, since my code hasn’t changed, is it possible that the API has (I know I know terribly unlikely). Do any of the upstanding and erudite members of StackO have any thoughts?

Btw, I have checked and my ConsumerKey/Secret are valid, as is the cached OAuth access token that my authentication section uses. It’s odd because I can pull my list of followers, check my rate limiting stats, etc. Also my NewtonSoft, Hammoch and TweetSharp references have not been updated/changed.

Thanks.

[SOURCE]

    private struct message
    {
        public long id;
        public string text;

        public message(long i, string t)
        {
            id = i;
            text = t;
        }
    }    

    private MessageEngine
    {
        /* Do auth -- excised for obvious reasons */

        Timer timer = new Timer();
        timer.Interval = 15000;
        timer.Tick += new EventHandler(timer_Tick);
        timer.Start();
    }    

    private List<message> GetDirectMessages()
    {
        try
        {
            //Declarations:
            message message = new message();
            List<message> messages = new List<message>();
/*line 344*/IEnumerable<TwitterDirectMessage> directMessages = service.ListDirectMessagesReceived();

            //Fetch all current direct message:
            foreach (TwitterDirectMessage directMessage in directMessages)
            {
                //Store each message into a list, in reverse older:
                message = new message(directMessage.Id, directMessage.Text);
                messages.Insert(0, message);
            }

            return messages;
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
            return null;
        }
    }

    private void timer_Tick(object sender, EventArgs e)
    {
        try
        {
            List<message> messages = GetDirectMessages();
            LocalExecute(messages);
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.ToString());
        }
    }

    private bool LocalExecute(List<message> messages)
    {
        /* process messages */
    }

[EXCEPTION]

Newtonsoft.Json.JsonSerializationException: Cannot deserialize JSON array into type 'TweetSharp.TwitterDirectMessage'.
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(Type objectType, JsonContract contract) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 412
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String reference) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 432
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 222
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract) in d:\Development\Releases\Json\Working\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalReader.cs:line 205
   at TweetSharp.Serialization.SerializerBase.DeserializeJson(String content, Type type) in C:\Users\Dimebrain\Desktop\Src\tweetsharp\src\vs2010\TweetSharp.Next\Serialization\SerializerBase.cs:line 60
   at TweetSharp.Serialization.JsonSerializer.AddDeserializedItem(String c, Type type, IList collection) in C:\Users\Dimebrain\Desktop\Src\tweetsharp\src\vs2010\TweetSharp.Next\Serialization\JsonSerializer.cs:line 131
   at TweetSharp.Serialization.JsonSerializer.DeserializeCollection[T](String content) in C:\Users\Dimebrain\Desktop\Src\tweetsharp\src\vs2010\TweetSharp.Next\Serialization\JsonSerializer.cs:line 90
   at TweetSharp.Serialization.JsonSerializer.Deserialize[T](String content) in C:\Users\Dimebrain\Desktop\Src\tweetsharp\src\vs2010\TweetSharp.Next\Serialization\JsonSerializer.cs:line 17
   at Hammock.RestClient.DeserializeEntityBody[T](RestBase request, RestResponse`1 response) in C:\Users\Dimebrain\Desktop\Src\hammock\src\net35\Hammock\RestClient.cs:line 2285
   at Hammock.RestClient.BuildResponseFromResult[T](RestBase request, WebQuery query) in C:\Users\Dimebrain\Desktop\Src\hammock\src\net35\Hammock\RestClient.cs:line 2212
   at Hammock.RestClient.Request[T](RestRequest request) in C:\Users\Dimebrain\Desktop\Src\hammock\src\net35\Hammock\RestClient.cs:line 107
   at TweetSharp.TwitterService.WithHammockImpl[T](RestRequest request) in C:\Users\Dimebrain\Desktop\Src\tweetsharp\src\vs2010\TweetSharp.Next\Service\TwitterService.cs:line 401
   at TweetSharp.TwitterService.WithHammock[T](String path) in C:\Users\Dimebrain\Desktop\Src\tweetsharp\src\vs2010\TweetSharp.Next\Service\TwitterService.cs:line 378
   at TweetSharp.TwitterService.WithHammock[T](String path, Object[] segments) in C:\Users\Dimebrain\Desktop\Src\tweetsharp\src\vs2010\TweetSharp.Next\Service\TwitterService.cs:line 383
   at TweetSharp_Test.Form1.GetDirectMessages() in C:\Users\kmarks2\Documents\Visual Studio 2008\Projects\TweetSharp_Test\TweetSharp_Test\Form1.cs:line 344
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T12:13:19+00:00Added an answer on May 19, 2026 at 12:13 pm

    As i can see from stack trace the TweetSharp.TwitterDirectMessage class schema is different from what was expected by Deserializer, may be the Json data passed has changed from last time you checked.

    Also I think the Tweetsharp had some issue related to this.

    As i checked in changeset on codeplex there was a change to Fix direct messages with IDs using fluent.

    Check it out here.

    http://tweetsharp.codeplex.com/SourceControl/changeset/changes/8bf46a5230bc

    Try downloading new TweetSharp v2.0.0.0 – Preview 9

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple StopWatch application in Silverlight. I have the following private
I have to write a simple mobile application that is able to receive broadcast
this is a weird thing. I created a simple SOAP based web service with
I am trying to write a simple, in-house file delivery application for uploading files
I have a simple task. I have an existing project with a web service
I'm working on the design of a remote control application. From my iPhone or
I was hoping to implement a simple XMPP server in Java. What I need
I want to write a MobileSubstrate ( http://www.iphonedevwiki.net/index.php/MobileSubstrate ) addon that takes every HTTP
I am in the process of setting up a web service for an external
I have to interface with a slightly archaic system that doesn't use webservices. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.