我注意到Twitterizer的一个问题是它一直工作正常,直到我的客户在她的帐户中添加了一条包含由Photobucket支持的图像的推文。
然后我们开始获取上面的Object引用错误。花了一两个小时来确定它实际上是导致我现在已经删除的问题的推文但是我怎么能解决这个问题呢?
我的代码在下面是一个非常基本的解决方案,用于拉动时间线:
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>";
}
为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
答案 0 :(得分:1)
我一直有这个问题。将Newtonsoft.json.dll降级为4.3。*为我解决了这个问题。
答案 1 :(得分:0)
这是Twitterizer库中的一个新bug。我没有机会确定原因,但在某些情况下,Twitter API返回的数据结构似乎发生了一些变化(我认为它与实体数据有关)。
或者,这是一个更糟糕的情况:它是JSON.NET库中的一个新bug,Twitterizer使用它来自动将json数据读入对象。