2012-06-04 48 views
0

我收到與帖子here類似的錯誤。MonoTouch中的JSON.Net的奇怪例外

我正在像JSON一樣在後臺線程上解析JSON。偶爾會失敗,並在Array.Copy中發生錯誤。

這裏是一個堆棧跟蹤:

System.NullReferenceException: Object reference not set to an instance of an object 
    at System.Array.Copy (System.Array sourceArray, Int32 sourceIndex, System.Array destinationArray, Int32 destinationIndex, Int32 length) [0x00104] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Array.cs:979 
    at System.Collections.ArrayList.CopyTo (Int32 index, System.Array array, Int32 arrayIndex, Int32 count) [0x0002d] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections/ArrayList.cs:3064 
    at System.Collections.ArrayList.CopyTo (System.Array array, Int32 arrayIndex) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Collections/ArrayList.cs:3046 
    at System.MonoCustomAttrs.GetCustomAttributes (ICustomAttributeProvider obj, System.Type attributeType, Boolean inherit) [0x0026c] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/MonoCustomAttrs.cs:259 
    at System.MonoType.GetCustomAttributes (System.Type attributeType, Boolean inherit) [0x00011] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/MonoType.cs:582 
    at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttributes[JsonConverterAttribute] (ICustomAttributeProvider attributeProvider, Boolean inherit) [0x00000] in <filename unknown>:0 
    at Newtonsoft.Json.Utilities.ReflectionUtils.GetAttribute[JsonConverterAttribute] (ICustomAttributeProvider attributeProvider, Boolean inherit) [0x00000] in <filename unknown>:0 
    ... Continues ... 

這裏是JSON.Net違規代碼:

#if !(NETFX_CORE) 
    public static T[] GetAttributes<T>(ICustomAttributeProvider attributeProvider, bool inherit) where T : Attribute 
    { 
     ValidationUtils.ArgumentNotNull(attributeProvider, "attributeProvider"); 

     object provider; 

#if !PORTABLE 
     provider = attributeProvider; 
#else 

... omitted junk ... 

     if (provider is Type) 
     return (T[])((Type)provider).GetCustomAttributes(typeof(T), inherit); 

我猜GetCustomAttributes被返回null。 Xamarin有沒有人知道這個問題?新聞組的人說他把這項工作放在主線上,並修復了它(但我不確定我想這麼做)。

+0

什麼是JSON的樣子? –

+0

這就是:{「ErrorCode」:660,「ErrorMessage」:「GameId不是當前回合。」} – jonathanpeppers

回答

2

這是一個known bug

它固定在5.3.3 alpha版本中。

+0

您是否在應用程序中使用過5.3.3?我會切換,但我們可能會在未來兩週內發佈應用商店。 ('alpha'這個詞讓我有點害怕) – jonathanpeppers

+0

我只是想將它推送給我們的TestFlight用戶,看看它是如何發生的。如果結果正確,請將其標記爲答案。 – jonathanpeppers