diff --git a/runtime/delegates.t4 b/runtime/delegates.t4 index 05eedd4a81..520a21a561 100644 --- a/runtime/delegates.t4 +++ b/runtime/delegates.t4 @@ -142,10 +142,10 @@ OnlyDynamicUsage = false, }, - new XDelegate ("MonoObject *", "IntPtr", "xamarin_get_inative_object_dynamic", + new XDelegate ("GCHandle->MonoObject *", "IntPtr", "xamarin_get_inative_object_dynamic", "id", "IntPtr", "obj", "bool", "bool", "owns", - "void *", "IntPtr", "type" + "GCHandle->MonoReflectionType *", "IntPtr", "type" ) { WrappedManagedFunction = "GetINativeObject_Dynamic", OnlyDynamicUsage = false, @@ -168,7 +168,7 @@ OnlyDynamicUsage = false, }, - new XDelegate ("MonoObject *", "IntPtr", "xamarin_get_inative_object_static", + new XDelegate ("GCHandle->MonoObject *", "IntPtr", "xamarin_get_inative_object_static", "id", "IntPtr", "obj", "bool", "bool", "owns", "unsigned int", "uint", "iface_token_ref", diff --git a/src/ObjCRuntime/Runtime.cs b/src/ObjCRuntime/Runtime.cs index 3f71a8754d..6eeb3e1f98 100644 --- a/src/ObjCRuntime/Runtime.cs +++ b/src/ObjCRuntime/Runtime.cs @@ -689,9 +689,8 @@ namespace ObjCRuntime { /* * This method is called from marshalling bridge (dynamic mode). */ - // It doesn't work to use System.Type in the signature, we get garbage. - var type = (System.Type) ObjectWrapper.Convert (type_ptr); - return ObjectWrapper.Convert (GetINativeObject (ptr, owns, type)); + var type = (System.Type) GetGCHandleTarget (type_ptr); + return AllocGCHandle (GetINativeObject (ptr, owns, type)); } static IntPtr GetINativeObject_Static (IntPtr ptr, bool owns, uint iface_token, uint implementation_token) @@ -702,7 +701,7 @@ namespace ObjCRuntime { var iface = Class.ResolveTypeTokenReference (iface_token); var type = Class.ResolveTypeTokenReference (implementation_token); - return ObjectWrapper.Convert (GetINativeObject (ptr, owns, iface, type)); + return AllocGCHandle (GetINativeObject (ptr, owns, iface, type)); } static IntPtr GetNSObjectWithType (IntPtr ptr, IntPtr type_ptr, out bool created)