* Copyright 2004-2009 Novell, Inc (http://www.novell.com)
* Copyright 2011-2014 Xamarin, Inc (http://www.xamarin.com)
*
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include "config.h"
static MonoReflectionType *
type_from_handle (MonoType *handle);
+/* Class lazy loading functions */
+static GENERATE_GET_CLASS_WITH_CACHE (remoting_services, System.Runtime.Remoting, RemotingServices)
+static GENERATE_GET_CLASS_WITH_CACHE (call_context, System.Runtime.Remoting.Messaging, CallContext)
+static GENERATE_GET_CLASS_WITH_CACHE (context, System.Runtime.Remoting.Contexts, Context)
+
static mono_mutex_t remoting_mutex;
static gboolean remoting_mutex_inited;
byte_array_class = mono_array_class_get (mono_defaults.byte_class, 1);
#ifndef DISABLE_JIT
- klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting", "RemotingServices");
+ klass = mono_class_get_remoting_services_class ();
method_rs_serialize = mono_class_get_method_from_name (klass, "SerializeCallData", -1);
g_assert (method_rs_serialize);
method_rs_deserialize = mono_class_get_method_from_name (klass, "DeserializeCallData", -1);
method_exc_fixexc = mono_class_get_method_from_name (klass, "FixRemotingException", -1);
g_assert (method_exc_fixexc);
- klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Messaging", "CallContext");
+ klass = mono_class_get_call_context_class ();
method_set_call_context = mono_class_get_method_from_name (klass, "SetCurrentCallContext", -1);
g_assert (method_set_call_context);
- klass = mono_class_from_name (mono_defaults.corlib, "System.Runtime.Remoting.Contexts", "Context");
+ klass = mono_class_get_context_class ();
method_needs_context_sink = mono_class_get_method_from_name (klass, "get_NeedsContextSink", -1);
g_assert (method_needs_context_sink);
#endif
static MonoObject *
mono_remoting_wrapper (MonoMethod *method, gpointer *params)
{
+ MonoError error;
MonoMethodMessage *msg;
MonoTransparentProxy *this_obj;
MonoObject *res, *exc;
mparams[i] = *((gpointer *)params [i]);
} else {
/* runtime_invoke expects a boxed instance */
- if (mono_class_is_nullable (mono_class_from_mono_type (sig->params [i])))
- mparams[i] = mono_nullable_box ((guint8 *)params [i], klass);
- else
+ if (mono_class_is_nullable (mono_class_from_mono_type (sig->params [i]))) {
+ mparams[i] = mono_nullable_box ((guint8 *)params [i], klass, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
+ } else
mparams[i] = params [i];
}
} else {
}
}
- return mono_runtime_invoke (method, method->klass->valuetype? mono_object_unbox ((MonoObject*)this_obj): this_obj, mparams, NULL);
+ res = mono_runtime_invoke_checked (method, method->klass->valuetype? mono_object_unbox ((MonoObject*)this_obj): this_obj, mparams, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
+
+ return res;
}
msg = mono_method_call_message_new (method, params, NULL, NULL, NULL);
- res = mono_remoting_invoke ((MonoObject *)this_obj->rp, msg, &exc, &out_args);
+ res = mono_remoting_invoke ((MonoObject *)this_obj->rp, msg, &exc, &out_args, &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
if (exc)
mono_raise_exception ((MonoException *)exc);
/* 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*/
MonoObject *
mono_marshal_xdomain_copy_value (MonoObject *val)
{
+ MonoError error;
MonoDomain *domain;
if (val == NULL) return NULL;
case MONO_TYPE_U8:
case MONO_TYPE_R4:
case MONO_TYPE_R8: {
- return mono_value_box (domain, mono_object_class (val), ((char*)val) + sizeof(MonoObject));
+ MonoObject *res = mono_value_box_checked (domain, mono_object_class (val), ((char*)val) + sizeof(MonoObject), &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
+ return res;
+
}
case MONO_TYPE_STRING: {
MonoString *str = (MonoString *) val;
- return (MonoObject *) mono_string_new_utf16 (domain, mono_string_chars (str), mono_string_length (str));
+ MonoObject *res = NULL;
+ res = (MonoObject *) mono_string_new_utf16_checked (domain, mono_string_chars (str), mono_string_length (str), &error);
+ mono_error_raise_exception (&error); /* FIXME don't raise here */
+ return res;
}
case MONO_TYPE_ARRAY:
case MONO_TYPE_SZARRAY: {