It's possible that the native pointer address has been reused (e.g. the
runtime thinks the old object is still around even tho it is not).

Jeff

On Thu, May 17, 2012 at 4:46 AM, Rolf Bjarne Kvinge <[email protected]>wrote:

> Hi,
>
> I just looked at the source and this is something that should not happen.
> We're looking up an object using the pointer to that object in a
> dictionary, and then casting the result to NSObject. The problem is that
> the only thing we ever put in that dictionary is NSObjects, i.e. it is
> impossible for this to happen, which leads to the possibility of memory
> corruption or GC bug. Is it a reproducible issue? We could probably give
> you instrumented monotouch.dlls which could help tracking it down if it
> happens for you once in a while.
>
> Rolf
>
> On Thu, May 17, 2012 at 9:44 AM, René Ruppert <[email protected]
> > wrote:
>
>> Hi,
>>
>>
>>
>> Can somebody give me an example that would lead to the exception below?
>>
>> Is that simply caused by trying to case a null ref into an NSObject?
>>
>> Would can cause this? Does it mean that there is a managed object that
>> tries to access its unmanaged counterpart that no longer exists?
>>
>>
>>
>> System.InvalidCastException: Cannot cast from source type to destination
>> type.
>>
>> at MonoTouch.ObjCRuntime.Runtime.TryGetNSObject (IntPtr ptr) [0x00000] in
>> <filename unknown>:0
>>
>> at MonoTouch.ObjCRuntime.Runtime.GetNSObject (IntPtr ptr) [0x00000] in
>> <filename unknown>:0
>>
>> at MonoTouch.ObjCRuntime.Runtime.GetNSObjectWrapped (IntPtr ptr)
>> [0x00000] in <filename unknown>:0
>>
>> at (wrapper native-to-managed)
>> MonoTouch.ObjCRuntime.Runtime:GetNSObjectWrapped (intptr)
>>
>>
>>
>>
>>
>> René
>>
>> _______________________________________________
>> MonoTouch mailing list
>> [email protected]
>> http://lists.ximian.com/mailman/listinfo/monotouch
>>
>>
>
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to