Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'mono/metadata/icall.c')
-rw-r--r--mono/metadata/icall.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/mono/metadata/icall.c b/mono/metadata/icall.c
index 08304a3c90d..6b73270845d 100644
--- a/mono/metadata/icall.c
+++ b/mono/metadata/icall.c
@@ -2167,8 +2167,16 @@ ves_icall_RuntimeFieldInfo_SetValueInternal (MonoReflectionFieldHandle field, Mo
case MONO_TYPE_VALUETYPE:
case MONO_TYPE_PTR:
isref = FALSE;
- if (!MONO_HANDLE_IS_NULL (value))
- v = (char*)mono_object_handle_pin_unbox (value, &value_gchandle);
+ if (!MONO_HANDLE_IS_NULL (value)) {
+ if (m_class_is_valuetype (mono_handle_class (value)))
+ v = (char*)mono_object_handle_pin_unbox (value, &value_gchandle);
+ else {
+ char* n = g_strdup_printf ("Object of type '%s' cannot be converted to type '%s'.", m_class_get_name (mono_handle_class (value)), m_class_get_name (mono_class_from_mono_type_internal (type)));
+ mono_error_set_argument (error, cf->name, n);
+ g_free (n);
+ return;
+ }
+ }
break;
case MONO_TYPE_STRING:
case MONO_TYPE_OBJECT: