0

我有以下要绑定的属性:

@property (nonatomic, readwrite, retain) NSArray* activeTasks;

我与以下代码绑定:

[Export("activeTasks", ArgumentSemantic.Retain)]
NSDictionary[] ActiveTasks { get; } 

我经常使用这个属性。尽管如此,每千次访问,我就会在 get_activeTasks (选择器的绑定)上获得一个 SIGSEGV。我想知道我做错了什么,为什么这种情况很少发生而不是系统地发生。

  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend (intptr,intptr) <IL 0x00024, 0xffffffff>
  at MonoTouch.Foundation.NSObject.InitializeObject (bool) [0x00062] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:136
  at MonoTouch.Foundation.NSObject..ctor (intptr,bool) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:62
  at MonoTouch.Foundation.NSObject..ctor (intptr) <IL 0x00003, 0x0002b>
  at MonoTouch.Foundation.NSDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at MonoTouch.Foundation.NSMutableDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___intptr (object,intptr,intptr,intptr) <IL 0x00054, 0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) <IL 0x00030, 0xffffffff>
  at System.Reflection.MonoCMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00109] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:536
  at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:551
  at System.Activator.CreateInstance (System.Type,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo,object[]) [0x00174] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:299
  at System.Activator.CreateInstance (System.Type,object[],object[]) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:234
  at System.Activator.CreateInstance (System.Type,object[]) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System/Activator.cs:229
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (intptr,intptr) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:210
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (intptr) [0x0001f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:259
  at MonoTouch.Foundation.NSArray.ArrayFromHandle<T> (intptr) [0x0003a] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:172
  at TouchDBBinding.CouchServer.get_ActiveTasks () <IL 0x0001b, 0x00073>

编辑:

这是使用新框架的更新堆栈跟踪,我不知道它是否可以提供更多帮助:

堆栈跟踪:

 at (wrapper managed-to-native) MonoTouch.Foundation.NSObject.monotouch_create_managed_ref (intptr,intptr,bool) <IL 0x0002d, 0xffffffff>
  at MonoTouch.Foundation.NSObject.CreateManagedRef (bool) [0x00000] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:93
  at MonoTouch.Foundation.NSObject.InitializeObject (bool) [0x000cc] in /Developer/MonoTouch/Source/monotouch/src/Foundation/NSObject.cs:88
  at MonoTouch.Foundation.NSObject..ctor (intptr,bool) [0x0000d] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSObject2.cs:85
  at MonoTouch.Foundation.NSObject..ctor (intptr) <IL 0x00003, 0x0002b>
  at MonoTouch.Foundation.NSDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at MonoTouch.Foundation.NSMutableDictionary..ctor (intptr) <IL 0x00002, 0x00027>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___intptr (object,intptr,intptr,intptr) <IL 0x00054, 0xffffffff>
  at (wrapper managed-to-native) System.Reflection.MonoCMethod.InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&) <IL 0x00030, 0xffffffff>
  at System.Reflection.MonoCMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00109] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:530
  at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:545
  at System.Reflection.ConstructorInfo.Invoke (object[]) [0x0000e] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
  at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (intptr,intptr) [0x00051] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:269
  at MonoTouch.ObjCRuntime.Runtime.GetNSObject (intptr) [0x0001f] in /Developer/MonoTouch/Source/monotouch/src/ObjCRuntime/Runtime.cs:328
  at MonoTouch.Foundation.NSArray.ArrayFromHandle<T> (intptr) [0x00044] in /Developer/MonoTouch/Source/monotouch/src/shared/Foundation/NSArray.cs:188
  at TouchDBBinding.CouchServer.get_ActiveTasks () <IL 0x0001b, 0x00073>

当具有保留的 NSArray* 绑定到 NSDictionary[] 并且该属性为空时,MonoTouch 的内部工作是否可能存在问题?还是有可能是因为它的内容为空?

谢谢,保罗

4

1 回答 1

1

堆栈跟踪表明当 MonoTouch 尝试保留 NSArray 的元素之一时发生崩溃。

一个可能的原因是特定元素已被释放(或以其他方式损坏)。特别是这不是因为元素为空(这种情况的处理方式不同)。

于 2013-04-11T21:14:39.493 回答