0

I have noticed a problem with Twitterizer in that it's has been working fine until my client added a tweet to her account containing an image powered by Photobucket.

Then we started getting the Object reference error above. It's taken a an hour or two to determine that it was actually the tweet causing the issue which I've now removed however how can I get round this problem?

My code is below which is a very basic solution for pulling the time line in:

OAuthTokens tokens = new OAuthTokens();
tokens.AccessToken = AccessToken;
tokens.AccessTokenSecret = AccessTokenSecret;
tokens.ConsumerKey = ConsumerKey;
tokens.ConsumerSecret = ConsumerSecret;

try
{
  UserTimelineOptions opts = new UserTimelineOptions();
  opts.IncludeRetweets = false;
  opts.UseSSL = true;
  opts.Count = 5;

  /* Throws Exception -> */ TwitterResponse<TwitterStatusCollection> timeLine =  TwitterTimeline.UserTimeline(tokens, opts);
  uxTweets.DataSource = timeLine.ResponseObject;
  uxTweets.DataBind();
}
catch
{
  uxError.Text = "<p class=\"p1\">Twitter isn't configured correctly. Twitter is not responding.</p>";
}

Updated Stack Trace for Brian:

[NullReferenceException: Object reference not set to an instance of an object.]
   Twitterizer.Entities.Converter.ReadJson(JsonReader reader, Type objectType, Object existingValue, JsonSerializer serializer) +1355
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueProperty(JsonReader reader, JsonProperty property, Object target, Boolean gottenCurrentValue, Object currentValue) +165
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.SetPropertyValue(JsonProperty property, JsonReader reader, Object target) +476
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateObject(Object newObject, JsonReader reader, JsonObjectContract contract, String id) +702
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateObject(JsonReader reader, JsonObjectContract contract, String id) +110
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) +867
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) +92
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, String reference, JsonArrayContract contract) +495
   Newtonsoft.Json.Serialization.<>c__DisplayClass1.<CreateAndPopulateList>b__0(IList l, Boolean isTemporaryListReference) +98
   Newtonsoft.Json.Utilities.CollectionUtils.CreateAndPopulateList(Type listType, Action`2 populateList) +554
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateAndPopulateList(JsonReader reader, String reference, JsonArrayContract contract) +103
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String reference) +61
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue) +119
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueNonProperty(JsonReader reader, Type objectType, JsonContract contract) +130
   Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType) +94
   Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType) +47
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings) +105
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value, JsonSerializerSettings settings) +74
   Newtonsoft.Json.JsonConvert.DeserializeObject(String value) +42
   Twitterizer.Core.SerializationHelper`1.Deserialize(Byte[] webResponseData, DeserializationHandler deserializationHandler) +91
   Twitterizer.Core.TwitterCommand`1.ExecuteCommand() +2867
   Twitterizer.TwitterTimeline.UserTimeline(OAuthTokens tokens, UserTimelineOptions options) +48
   DataComuniqueUtils.Twitter.Page_Load(Object sender, EventArgs e) in C:\Users\Paul Stoker\Documents\Visual Studio 2010\Projects\DataComuniqueUtils\DataComuniqueUtils\Twitter.ascx.cs:41
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +74
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Control.LoadRecursive() +146
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
4

2 回答 2

1

我一直有这个问题。将 Newtonsoft.json.dll 降级到 4.3.* 为我解决了这个问题。

于 2012-03-13T05:09:38.417 回答
0

这是 Twitterizer 库中的一个新错误。我还没有机会确定原因,但它似乎是在某些情况下 Twitter API 返回的数据结构发生了一些变化(我相信它与实体数据有关)。

或者,这是更糟糕的情况:这是 JSON.NET 库中的一个新错误,Twitterizer 使用该库将 json 数据自动读取到对象中。

于 2012-03-06T21:42:26.693 回答