X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmetadata%2Fremoting.c;h=6555cdec7a0d49f1e7da05a0cd841ca99bf47139;hb=ef0ddf45c3081e799edcb4e95770186514b80cf1;hp=6e84ab7c0c44633abf57ef9973dd3d03437ffa3c;hpb=3d22da0f6e0a1ffa04d09893899e8b277e1f8f9e;p=mono.git diff --git a/mono/metadata/remoting.c b/mono/metadata/remoting.c index 6e84ab7c0c4..6555cdec7a0 100644 --- a/mono/metadata/remoting.c +++ b/mono/metadata/remoting.c @@ -5,6 +5,7 @@ * 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" @@ -66,6 +67,11 @@ mono_marshal_xdomain_copy_out_value (MonoObject *src, MonoObject *dst); 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; @@ -153,7 +159,7 @@ mono_remoting_marshal_init (void) 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); @@ -169,11 +175,11 @@ mono_remoting_marshal_init (void) 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 @@ -340,6 +346,7 @@ mono_remoting_mb_create_and_cache (MonoMethod *key, MonoMethodBuilder *mb, static MonoObject * mono_remoting_wrapper (MonoMethod *method, gpointer *params) { + MonoError error; MonoMethodMessage *msg; MonoTransparentProxy *this_obj; MonoObject *res, *exc; @@ -367,9 +374,10 @@ mono_remoting_wrapper (MonoMethod *method, gpointer *params) 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 { @@ -377,12 +385,16 @@ mono_remoting_wrapper (MonoMethod *method, gpointer *params) } } - 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); @@ -1977,6 +1989,7 @@ mono_get_xdomain_marshal_type (MonoType *t) MonoObject * mono_marshal_xdomain_copy_value (MonoObject *val) { + MonoError error; MonoDomain *domain; if (val == NULL) return NULL; @@ -1998,11 +2011,17 @@ mono_marshal_xdomain_copy_value (MonoObject *val) 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: {