Skip to content

Commit

Permalink
[runtime] Avoid an assert if a runtime compiled without DISABLE_COM i…
Browse files Browse the repository at this point in the history
…s used with an mscorlib from the mobile_static profile.
  • Loading branch information
vargaz committed Jan 29, 2016
1 parent c52c794 commit 3d22da0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
16 changes: 16 additions & 0 deletions mono/metadata/cominterop.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ mono_marshal_safearray_set_value (gpointer safearray, gpointer indices, gpointer
static void
mono_marshal_safearray_free_indices (gpointer indices);

MonoClass*
mono_class_try_get_com_object_class (void)
{
static MonoClass *tmp_class;
static gboolean inited;
MonoClass *klass;
if (!inited) {
klass = mono_class_from_name (mono_defaults.corlib, "System", "__ComObject");
mono_memory_barrier ();
tmp_class = klass;
mono_memory_barrier ();
inited = TRUE;
}
return tmp_class;
}

/**
* cominterop_method_signature:
* @method: a method
Expand Down
3 changes: 3 additions & 0 deletions mono/metadata/cominterop.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,7 @@ mono_string_from_bstr (gpointer bstr);
MONO_API void
mono_free_bstr (gpointer bstr);

MonoClass*
mono_class_try_get_com_object_class (void);

#endif /* __MONO_COMINTEROP_H__ */
2 changes: 1 addition & 1 deletion mono/metadata/remoting.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ mono_marshal_get_remoting_invoke (MonoMethod *method)

/* this seems to be the best plase to put this, as all remoting invokes seem to get filtered through here */
#ifndef DISABLE_COM
if (mono_class_is_com_object (method->klass) || method->klass == mono_class_get_com_object_class ()) {
if (mono_class_is_com_object (method->klass) || method->klass == mono_class_try_get_com_object_class ()) {
MonoVTable *vtable = mono_class_vtable (mono_domain_get (), method->klass);
g_assert (vtable); /*FIXME do proper error handling*/

Expand Down

0 comments on commit 3d22da0

Please sign in to comment.