+ guint32 methodref_token = mono_image_get_methodref_token (assembly, method, create_open_instance);
+ /* We need to register a 'canonical' object. The same
+ * MonoMethod could have been reflected via different
+ * classes so the MonoReflectionMethod:reftype could be
+ * different, and the object lookup in
+ * dynamic_image_register_token would assert assert. So
+ * we pick the MonoReflectionMethod object that has the
+ * reflected type as NULL (ie, take the declaring type
+ * of the method) */
+ MonoReflectionMethodHandle canonical_obj =
+ mono_method_get_object_handle (MONO_HANDLE_DOMAIN (obj), method, NULL, error);
+ if (!is_ok (error))
+ goto leave;
+ MONO_HANDLE_ASSIGN (register_obj, canonical_obj);
+ token = methodref_token;