2012-03-01 65 views
0

我注意到Twitterizer存在一個問題,它一直工作正常,直到我的客戶端向她的帳戶添加了一條推文,其中包含由Photobucket支持的圖像。Twitterizer-未將對象引用設置爲對象的實例

然後我們開始獲取上面的對象引用錯誤。我們花了一兩個小時才確定它實際上是引發我現在已經刪除的問題的推文,但是我怎樣才能解決這個問題?

我的代碼是下面這對於拉動時間線中一個非常基本的解決方案:

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>"; 
} 

更新堆棧跟蹤布萊恩:

[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 
+1

請包括來自異常的堆棧跟蹤。 – 2012-03-02 00:03:11

+0

錯誤通常表示正在將某物分配給空對象。你能明確哪一行代碼觸發了這個嗎? – Bahamut 2012-03-04 13:06:13

+0

感謝Bahamut,我編輯了帖子以顯示引發異常的位置。我不認爲Twitterizer.Entities庫已經更新,以處理圖像,除非我完全失去了一些東西? – Stokedout 2012-03-04 14:26:44

回答

1

我一直有這個問題。將Newtonsoft.json.dll降級到4.3。*解決了我的問題。

0

這是一個新的bug Twitterizer庫。我沒有機會確定原因,但在某些情況下(我相信它與實體數據有關),Twitter API返回的數據結構似乎有所改變。

或者,這是一個更壞的情況:它是JSON.NET庫中的一個新bug,Twitterizer使用它來自動將json數據讀入對象。

+0

感謝您關注此Ricky,我會密切關注github的更新;-) – Stokedout 2012-03-07 20:02:26

相關問題