This project has moved and is read-only. For the latest updates, please go here.

Issues while getting users timeline.

Apr 4, 2012 at 6:11 PM

okay, so every thing seemed to be working fine but I am now hitting issues when logging in and trying to retrieve that users timeline was wondering if you had any ideas of what could possibly going wrong. The application is a ASP.NET MVC 4 .NET 4.

I think the issue is to do with how the context is being created. The user ID is present in the context under the auth object, however I seems to be getting -1 for request available and allot of other parameters.  however I have noticed whilst debugging that this has been 300 and then will go to -1 is it possible this is using all the requests instantaneously ? 


This is the query method 

        public static IQueryable<LinqToTwitter.Status> UsersTimeline(TwitterContext twitterCtx, Int32 Count = 30, Int32 Page = 1)
            return (from tweet in twitterCtx.Status
                        where tweet.Type == StatusType.Friends &&
                        tweet.Page == Page && 
                        tweet.Count == Count 
                        select tweet);


This is the code the error is being thrown on, obviously because the IQueryable can't be retrieved. 


        public static IEnumerable<TweetViewModels> toViewTeetViewModels(IEnumerable<Status> searchResults)
            return (from tweet in searchResults
                    select new TweetViewModels
                        ScreenName = tweet.User.Name,
                        ImageUrl = tweet.User.ProfileImageUrl,
                        Tweet = tweet.Text,
                        ID = tweet.ID.ToString()

Here is the provided stack trace


[NullReferenceException: Object reference not set to an instance of an object.]
   Sentimentor.Helpers.TwitterHelper.<toViewTeetViewModels>b__e(Status tweet) in C:\WebsiteProjects\Sentimentor\Sentimentor\Sentimentor\Helpers\TwitterHelper.cs:98
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +237
   ASP._Page_Views_Shared_TweetsClassifier_cshtml.Execute() in c:\WebsiteProjects\Sentimentor\Sentimentor\Sentimentor\Views\Shared\TweetsClassifier.cshtml:21
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +279
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +103
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +142
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +180
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +383
   System.Web.Mvc.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() +32
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) +848388
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +265
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +847456
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375




Apr 4, 2012 at 7:09 PM


The exception is a NullReferenceException, meaning that something you're trying to access is null.  I would materialize the query first (without the projection), and then transform the data (with projection) into ViewModels, which will help you see where the exception is happening.

BTW, User has a UserIdentifier property that you can use for getting ID and ScreenName.  The ID, UserID, and ScreenName of the Status instance is for input queries only.


Apr 5, 2012 at 9:48 AM

Hi Joe, 

Thanks for your prompt reply. 

The issue was with me trying to take the current tweet ID on the transform. 

Thanks Again.