未处理的类型' System.Reflection.TargetInvocationException'发生在System.Windows.ni.dll中

时间:2015-09-03 07:55:38

标签: c# asp.net windows-phone-7 windows-phone-8.1

我正致力于Windows Phone 8.1尝试从图谱API facebook获取用户状态。

代码在此行上给出了未经处理的异常
MyChartFacebook.DataContext = grouped;//exception on this line

例外:
An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in System.Windows.ni.dll Additional information: Exception has been thrown by the target of an invocation

enter image description here

我尝试了什么:
这个例外报告了许多问题,例如Q,但似乎没有人解决我的问题。此代码也适用于其他情况,但我无法弄清楚为什么它会在这里给出例外。

我的代码:

 private void FqlSampleGetUserSatuts()
        {
            var fb = new FacebookClient(accessTokenFacebook);
            try
            {
                fb.GetCompleted += (o, e) =>
                  {
                      if (e.Error != null)
                      {
                          Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message));
                          return;
                      }


                      object ListData = e.GetResultData();
                      string feeds = ListData.ToString();

                      RootObjectStatusNew root = JsonConvert.DeserializeObject<RootObjectStatusNew>(feeds);

                      if (root.posts != null)
                      {
                          var grouped = (from c in root.posts.data
                                         group c by new { c.updated_time } into g
                                         select new graphdata
                                         {
                                             count = g.Count(),
                                             key = g.Key.updated_time,
                                         }).ToList();


                          Dispatcher.BeginInvoke(() =>
                          {

                              if (grouped != null)
                              {

                                  MyChartFacebook.DataContext = grouped;//exception on this line
                                  Status_List = grouped;
                                  MyChartFacebook.Title = "  My Status";
                                  SystemTray.IsVisible = false;
                              }
                              else
                              {
                                  MessageBox.Show("Sorry Data not Found");
                              }

                          });

                      }
                  };

                fb.GetAsync("me?fields=posts.limit(200).fields(updated_time)");

            }
            catch (Exception)
            { }
        }

0 个答案:

没有答案