Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Arithmetic operation resulted in an overflow excepiton on tweetsharp

Tags:

c#

twitter

Hi I have a problem with tweetsharp sdk. I try to read tweets with the code below, sometimes not always I take this exception: "Arithmetic operation resulted in an overflow". I searched but coludn't find the reason?

TweetSharp.TwitterService tester = new TwitterService();

tester.AuthenticateWith(consumerkey, consumersecret, accesstoken, accesstokensecret);

var a = tester.Search(new SearchOptions { Q = "screenname", Count = 100}); //On this line i take the excepiton
like image 215
user2933990 Avatar asked Oct 29 '13 21:10

user2933990


People also ask

Is arithmetic overflow an exception?

With the default setting, C# compiler will not throw an exception if arithmetic overflow happens. The above program will not throw an exception and work fine because C# compiler is configured in that way.

How do you handle arithmetic overflow exception in C#?

If you want to ensure that arithmetic operations will throw overflow exceptions if an overflow happens, you need to use the checked { ... } code block. When using the checked { ... } code block, if any arithmetic operation causes an overflow, an OverflowException will be thrown, and will need to be catched and handled.


1 Answers

As an alternative to building the source (which can be tricky due to Windows Phone SDK dependencies etc.) you could give this fork a try:
https://github.com/timothy-makarov/tweetsharp

It's an unofficial bug fork for TweetSharp wrapped in a NuGet package:
http://www.nuget.org/packages/TweetSharp-Unofficial/

We came from TweetSharp v2.3.0, and updating to TweetSharp v2.3.1 did not solve our JSON deserialize problems. Replacing it with the unofficial v.2.3.1.2 package did though.

like image 94
Fredrik Rofors Avatar answered Sep 30 '22 12:09

Fredrik Rofors