Sample on Home page not working

Jul 12, 2012 at 11:44 PM
Edited Jul 12, 2012 at 11:47 PM

When I try running the example code on the home (below) I get the following error 
"Invalid token '34' in input string" on the line:

Search srch = queryResults.Single();

Example code:

           var twitterCtx = new TwitterContext();

            var queryResults =
                from search in twitterCtx.Search
                where search.Type == SearchType.Search &&
                      search.Query == "Linq To Twitter"
                select search;

            Search srch = queryResults.Single();

            Console.WriteLine("\nQuery: {0}\n", srch.QueryResult);
            srch.Results.ForEach(entry => 
                Console.WriteLine(
                    "ID: {0, -15}, Source: {1}\nContent: {2}\n",
                    entry.ID, entry.Source, entry.Text));

Stack Trace:

   at LinqToTwitter.TwitterQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.Single[TSource](IQueryable`1 source)
   at ScratchTwitterWPF.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e) in
...


InnerException: "The given key was not present in the dictionary."

 

Stack Trace:

 

   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)   
      at LitJson.JsonReader.Read()

 

Any suggestions?

Thanks

Tim

Coordinator
Jul 12, 2012 at 11:55 PM

Hi Tim,

This is a known issue that started occurring within the last week - Twitter returning only part of the results at a time.  I have a fix for it already checked-in, which is a blocking read on the response stream.  You can download the source code to do a build and use that if you need to right away.  I'll do a release soon, as it's probably something that's beginning to have more widespread affect.

Joe

Jul 13, 2012 at 12:18 AM

Awesome  - thanks for the speedy reply and solving the problem - much appreciated!

Will try downloading the code.

 

Cheers

t

Jul 13, 2012 at 12:46 AM

Tried downloading and building the latest version - but same error.

 

Can you please confirm I got the code from the right place:   - On Source Code tab, in the Latest Version panel on the right side (which I noticed said 'master' branch), I clicked on the Download link.  Is this correct?

Coordinator
Jul 13, 2012 at 1:21 AM

It looks like you got the right version.  I'll have to take a closer look.

Joe

Coordinator
Jul 15, 2012 at 2:44 AM

I took another look at this and wasn't able to reproduce.  I did a new release today, so you might want to try the new binaries, or NuGet, in case you accidentally got the wrong DLL.

Also, make sure your clock is set properly because a mismatch will cause authentication problems with Twitter.

Joe

May 10, 2013 at 4:44 AM
Edited May 10, 2013 at 4:45 AM
We have the below issue from CRM 2011, any help please ...

Event code: 3005
Event message: An unhandled exception has occurred.
Event time: 10.05.2013 05:30:46
Event time (UTC): 10.05.2013 03:30:46
Event ID: 602d23deaf504894ae8e0c84f581b3fc
Event sequence: 16
Event occurrence: 5
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/7/ROOT-1-130126296015720179 
Trust level: Full 
Application Virtual Path: / 
Application Path: D:\Current\TwitterASPX\TwitterASPX\TwitterASPX\ 
Machine name: DEMO-3 
Process information:
Process ID: 2772 
Process name: w3wp.exe 
Account name: IIS APPPOOL\Tweet 
Exception information:
Exception type: JsonException 
Exception message: Invalid token '34' in input string
at LinqToTwitter.TwitterQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable1 source)
at Redknee_MSCRM_Apps.TwitterGlobal.Search()
at Redknee_MSCRM_Apps.TwitterGlobal.radGrid_NeedDataSource(Object source, GridNeedDataSourceEventArgs e)
at Telerik.Web.UI.RadGrid.OnNeedDataSource(GridNeedDataSourceEventArgs e)
at Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason)
at Telerik.Web.UI.RadGrid.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary
2.get_Item(TKey key)
at LitJson.JsonReader.Read()



Request information:
Request URL: http://localhost:8081/TwitterGlobal.aspx?orgname=Redknee 
Request path: /TwitterGlobal.aspx 
User host address: 127.0.0.1 
User: REDKNEELABS\depadmin 
Is authenticated: True 
Authentication Type: Negotiate 
Thread account name: IIS APPPOOL\Tweet 
Thread information:
Thread ID: 26 
Thread account name: IIS APPPOOL\Tweet 
Is impersonating: False 
Stack trace:    at LinqToTwitter.TwitterQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source)
at Redknee_MSCRM_Apps.TwitterGlobal.Search()
at Redknee_MSCRM_Apps.TwitterGlobal.radGrid_NeedDataSource(Object source, GridNeedDataSourceEventArgs e)
at Telerik.Web.UI.RadGrid.OnNeedDataSource(GridNeedDataSourceEventArgs e)
at Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason)
at Telerik.Web.UI.RadGrid.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


Custom event details:
Coordinator
May 10, 2013 at 5:49 AM
Hi,

Whenever there's an exception in the Json parser, it usually means that you're getting an incomplete response from Twitter. It also occurs in disconnect scenarios where you lose the connection during the query or are not connected at all.

You can use Fiddler to tell if Twitter is sending a complete Json response.

To help with the situation, you should perform exception handling. A useful strategy is to catch the exception and retry a couple times to see if the network problems clear up. If it's possible, you might check to see if you have a network connection before retrying.

@JoeMayo