2004-04-07 Martin Baulig <martin@ximian.com>
[mono.git] / mono / metadata / icall.c
index b9143c8372fd61caff3e7cc9dc08faa8d4a950df..b350488800af2bbcd2316e72565aa10f3446bd29 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <mono/metadata/object.h>
 #include <mono/metadata/threads.h>
+#include <mono/metadata/threadpool.h>
 #include <mono/metadata/monitor.h>
 #include <mono/metadata/reflection.h>
 #include <mono/metadata/assembly.h>
@@ -42,6 +43,9 @@
 #include <mono/metadata/environment.h>
 #include <mono/metadata/profiler-private.h>
 #include <mono/metadata/locales.h>
+#include <mono/metadata/filewatcher.h>
+#include <mono/metadata/char-conversions.h>
+#include <mono/metadata/security.h>
 #include <mono/io-layer/io-layer.h>
 #include <mono/utils/strtod.h>
 #include <mono/utils/monobitset.h>
@@ -462,6 +466,7 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
        MonoClass *aklass;
        MonoArray *array;
        gint32 *sizes, i;
+       gboolean bounded = FALSE;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -476,7 +481,13 @@ ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *
                if (mono_array_get (lengths, gint32, i) < 0)
                        mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
 
-       aklass = mono_array_class_get (mono_class_from_mono_type (type->type), mono_array_length (lengths));
+       if (bounds && (mono_array_length (bounds) == 1) && (mono_array_get (bounds, gint32, 0) != 0))
+               /* vectors are not the same as one dimensional arrays with no-zero bounds */
+               bounded = TRUE;
+       else
+               bounded = FALSE;
+
+       aklass = mono_bounded_array_class_get (mono_class_from_mono_type (type->type), mono_array_length (lengths), bounded);
 
        sizes = alloca (aklass->rank * sizeof(guint32) * 2);
        for (i = 0; i < aklass->rank; ++i) {
@@ -753,6 +764,8 @@ ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fi
                MonoClassField *field = &klass->fields [i];
                if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
                        continue;
+               if (mono_field_is_deleted (field))
+                       continue;
                /* FIXME: Add more types */
                switch (field->type->type) {
                case MONO_TYPE_I4:
@@ -803,14 +816,16 @@ ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray
        /*
         * Do the comparison for fields of primitive type and return a result if
         * possible. Otherwise, return the remaining fields in an array to the 
-     * managed side. This way, we can avoid costly reflection operations in 
-     * managed code.
+        * managed side. This way, we can avoid costly reflection operations in 
+        * managed code.
         */
        *fields = NULL;
        for (i = 0; i < klass->field.count; ++i) {
                MonoClassField *field = &klass->fields [i];
                if (field->type->attrs & FIELD_ATTRIBUTE_STATIC)
                        continue;
+               if (mono_field_is_deleted (field))
+                       continue;
                /* FIXME: Add more types */
                switch (field->type->type) {
                case MONO_TYPE_I4:
@@ -860,7 +875,10 @@ ves_icall_System_Object_GetType (MonoObject *obj)
 {
        MONO_ARCH_SAVE_REGS;
 
-       return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
+       if (obj->vtable->klass != mono_defaults.transparent_proxy_class)
+               return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
+       else
+               return mono_type_get_object (mono_object_domain (obj), &((MonoTransparentProxy*)obj)->remote_class->proxy_class->byval_arg);
 }
 
 static void
@@ -1063,6 +1081,8 @@ handle_enum:
        case MONO_TYPE_SZARRAY:
        case MONO_TYPE_ARRAY:
        case MONO_TYPE_OBJECT:
+       case MONO_TYPE_VAR:
+       case MONO_TYPE_MVAR:
                return TYPECODE_OBJECT;
        case MONO_TYPE_CLASS:
                {
@@ -1073,6 +1093,8 @@ handle_enum:
                        }
                }
                return TYPECODE_OBJECT;
+       case MONO_TYPE_GENERICINST:
+               return TYPECODE_OBJECT;
        default:
                g_error ("type 0x%02x not handled in GetTypeCode()", t);
        }
@@ -1120,6 +1142,13 @@ ves_icall_type_is_assignable_from (MonoReflectionType *type, MonoReflectionType
        return mono_class_is_assignable_from (klass, klassc);
 }
 
+static guint32
+ves_icall_type_IsInstanceOfType (MonoReflectionType *type, MonoObject *obj)
+{
+       MonoClass *klass = mono_class_from_mono_type (type->type);
+       return mono_object_isinst (obj, klass) != NULL;
+}
+
 static guint32
 ves_icall_get_attributes (MonoReflectionType *type)
 {
@@ -1233,7 +1262,7 @@ ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *ob
        if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
                is_static = TRUE;
                vtable = mono_class_vtable (domain, field->klass);
-               if (!vtable->initialized)
+               if (!vtable->initialized && !(cf->type->attrs & FIELD_ATTRIBUTE_LITERAL))
                        mono_runtime_class_init (vtable);
        }
        
@@ -1311,18 +1340,41 @@ ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *ob
        }
 }
 
+/* From MonoProperty.cs */
+typedef enum {
+       PInfo_Attributes = 1,
+       PInfo_GetMethod  = 1 << 1,
+       PInfo_SetMethod  = 1 << 2,
+       PInfo_ReflectedType = 1 << 3,
+       PInfo_DeclaringType = 1 << 4,
+       PInfo_Name = 1 << 5
+} PInfo;
+
 static void
-ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info)
+ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info)
 {
        MonoDomain *domain = mono_object_domain (property); 
 
        MONO_ARCH_SAVE_REGS;
 
-       info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
-       info->name = mono_string_new (domain, property->property->name);
-       info->attrs = property->property->attrs;
-       info->get = property->property->get ? mono_method_get_object (domain, property->property->get, NULL): NULL;
-       info->set = property->property->set ? mono_method_get_object (domain, property->property->set, NULL): NULL;
+       if ((req_info & PInfo_ReflectedType) != 0)
+               info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
+       else if ((req_info & PInfo_DeclaringType) != 0)
+               info->parent = mono_type_get_object (domain, &property->property->parent->byval_arg);
+
+       if ((req_info & PInfo_Name) != 0)
+               info->name = mono_string_new (domain, property->property->name);
+
+       if ((req_info & PInfo_Attributes) != 0)
+               info->attrs = property->property->attrs;
+
+       if ((req_info & PInfo_GetMethod) != 0)
+               info->get = property->property->get ?
+                           mono_method_get_object (domain, property->property->get, NULL): NULL;
+       
+       if ((req_info & PInfo_SetMethod) != 0)
+               info->set = property->property->set ?
+                           mono_method_get_object (domain, property->property->set, NULL): NULL;
        /* 
         * There may be other methods defined for properties, though, it seems they are not exposed 
         * in the reflection API 
@@ -1336,7 +1388,9 @@ ves_icall_get_event_info (MonoReflectionEvent *event, MonoEventInfo *info)
 
        MONO_ARCH_SAVE_REGS;
 
-       info->parent = mono_type_get_object (domain, &event->klass->byval_arg);
+       info->declaring_type = mono_type_get_object (domain, &event->klass->byval_arg);
+       info->reflected_type = mono_type_get_object (domain, &event->event->parent->byval_arg);
+
        info->name = mono_string_new (domain, event->event->name);
        info->attrs = event->event->attrs;
        info->add_method = event->event->add ? mono_method_get_object (domain, event->event->add, NULL): NULL;
@@ -1358,6 +1412,7 @@ ves_icall_Type_GetInterfaces (MonoReflectionType* type)
 
        if (class->rank) {
                /* GetInterfaces() returns an empty array in MS.NET (this may be a bug) */
+               mono_bitset_free (slots);
                return mono_array_new (domain, mono_defaults.monotype_class, 0);
        }
 
@@ -1553,7 +1608,7 @@ ves_icall_MonoType_GetArrayRank (MonoReflectionType *type)
 }
 
 static MonoArray*
-ves_icall_Type_GetGenericArguments (MonoReflectionType *type)
+ves_icall_MonoType_GetGenericArguments (MonoReflectionType *type)
 {
        MonoArray *res;
        MonoClass *klass, *pklass;
@@ -1571,7 +1626,7 @@ ves_icall_Type_GetGenericArguments (MonoReflectionType *type)
                        mono_array_set (res, gpointer, i, mono_type_get_object (mono_object_domain (type), &pklass->byval_arg));
                }
        } else if (klass->generic_inst) {
-               MonoGenericInst *inst = klass->generic_inst->data.generic_inst;
+               MonoGenericInst *inst = klass->generic_inst;
                res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, inst->type_argc);
                for (i = 0; i < inst->type_argc; ++i) {
                        mono_array_set (res, gpointer, i, mono_type_get_object (mono_object_domain (type), inst->type_argv [i]));
@@ -1608,7 +1663,7 @@ ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType *type)
                return type; /* check this one */
        }
        if (klass->generic_inst) {
-               MonoType *generic_type = klass->generic_inst->data.generic_inst->generic_type;
+               MonoType *generic_type = klass->generic_inst->generic_type;
                MonoClass *generic_class = mono_class_from_mono_type (generic_type);
 
                if (generic_class->wastypebuilder && generic_class->reflection_info)
@@ -1619,15 +1674,28 @@ ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType *type)
        return NULL;
 }
 
-static MonoReflectionGenericInst*
-ves_icall_Type_BindGenericParameters (MonoReflectionType *type, MonoArray *types)
+static MonoReflectionType*
+ves_icall_Type_BindGenericParameters (MonoReflectionType *type, MonoArray *type_array)
 {
+       MonoType *geninst, **types;
+       int i, count;
+
        MONO_ARCH_SAVE_REGS;
 
        if (type->type->byref)
                return NULL;
 
-       return mono_reflection_bind_generic_parameters (type, types);
+       count = mono_array_length (type_array);
+       types = g_new0 (MonoType *, count);
+
+       for (i = 0; i < count; i++) {
+               MonoReflectionType *t = mono_array_get (type_array, gpointer, i);
+               types [i] = t->type;
+       }
+
+       geninst = mono_reflection_bind_generic_parameters (type, count, types);
+
+       return mono_type_get_object (mono_object_domain (type), geninst);
 }
 
 static gboolean
@@ -1693,25 +1761,214 @@ ves_icall_TypeBuilder_get_IsGenericParameter (MonoReflectionTypeBuilder *tb)
 }
 
 static MonoReflectionType*
-ves_icall_TypeBuilder_define_generic_parameter (MonoReflectionTypeBuilder *tb, MonoReflectionGenericParam *gparam)
+ves_icall_MonoGenericInst_GetParentType (MonoReflectionGenericInst *type)
+{
+       MonoGenericInst *ginst;
+       MonoClass *klass;
+
+       MONO_ARCH_SAVE_REGS;
+
+       ginst = type->type.type->data.generic_inst;
+       if (!ginst || !ginst->parent || (ginst->parent->type != MONO_TYPE_GENERICINST))
+               return NULL;
+
+       klass = mono_class_from_mono_type (ginst->parent);
+       if (!klass->generic_inst && !klass->gen_params)
+               return NULL;
+
+       return mono_type_get_object (mono_object_domain (type), ginst->parent);
+}
+
+static MonoArray*
+ves_icall_MonoGenericInst_GetInterfaces (MonoReflectionGenericInst *type)
 {
-       guint32 index;
+       static MonoClass *System_Reflection_MonoGenericInst;
+       MonoGenericInst *ginst;
+       MonoDomain *domain;
+       MonoClass *klass;
+       MonoArray *res;
+       int i;
 
        MONO_ARCH_SAVE_REGS;
 
-       index = mono_array_length (tb->generic_params) - 1;
-       return mono_reflection_define_generic_parameter (tb, NULL, index, gparam);
+       if (!System_Reflection_MonoGenericInst) {
+               System_Reflection_MonoGenericInst = mono_class_from_name (
+                       mono_defaults.corlib, "System.Reflection", "MonoGenericInst");
+               g_assert (System_Reflection_MonoGenericInst);
+       }
+
+       domain = mono_object_domain (type);
+
+       ginst = type->type.type->data.generic_inst;
+       if (!ginst || !ginst->ifaces)
+               return mono_array_new (domain, System_Reflection_MonoGenericInst, 0);
+
+       klass = mono_class_from_mono_type (ginst->generic_type);
+
+       res = mono_array_new (domain, System_Reflection_MonoGenericInst, ginst->count_ifaces);
+
+       for (i = 0; i < ginst->count_ifaces; i++) {
+               MonoReflectionType *iface = mono_type_get_object (domain, ginst->ifaces [i]);
+
+               mono_array_set (res, gpointer, i, iface);
+       }
+
+       return res;
 }
 
-static MonoReflectionType*
-ves_icall_MethodBuilder_define_generic_parameter (MonoReflectionMethodBuilder *mb, MonoReflectionGenericParam *gparam)
+static MonoArray*
+ves_icall_MonoGenericInst_GetMethods (MonoReflectionGenericInst *type,
+                                     MonoReflectionType *reflected_type)
+{
+       MonoGenericInst *ginst;
+       MonoDynamicGenericInst *dginst;
+       MonoDomain *domain;
+       MonoClass *refclass;
+       MonoArray *res;
+       int i;
+
+       MONO_ARCH_SAVE_REGS;
+
+       ginst = type->type.type->data.generic_inst;
+       g_assert ((dginst = ginst->dynamic_info) != NULL);
+
+       refclass = mono_class_from_mono_type (reflected_type->type);
+
+       domain = mono_object_domain (type);
+       res = mono_array_new (domain, mono_defaults.method_info_class, dginst->count_methods);
+
+       for (i = 0; i < dginst->count_methods; i++)
+               mono_array_set (res, gpointer, i,
+                               mono_method_get_object (domain, dginst->methods [i], refclass));
+
+       return res;
+}
+
+static MonoArray*
+ves_icall_MonoGenericInst_GetConstructors (MonoReflectionGenericInst *type,
+                                          MonoReflectionType *reflected_type)
+{
+       static MonoClass *System_Reflection_ConstructorInfo;
+       MonoGenericInst *ginst;
+       MonoDynamicGenericInst *dginst;
+       MonoDomain *domain;
+       MonoClass *refclass;
+       MonoArray *res;
+       int i;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (!System_Reflection_ConstructorInfo)
+               System_Reflection_ConstructorInfo = mono_class_from_name (
+                       mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
+
+       ginst = type->type.type->data.generic_inst;
+       g_assert ((dginst = ginst->dynamic_info) != NULL);
+
+       refclass = mono_class_from_mono_type (reflected_type->type);
+
+       domain = mono_object_domain (type);
+       res = mono_array_new (domain, System_Reflection_ConstructorInfo, dginst->count_ctors);
+
+       for (i = 0; i < dginst->count_ctors; i++)
+               mono_array_set (res, gpointer, i,
+                               mono_method_get_object (domain, dginst->ctors [i], refclass));
+
+       return res;
+}
+
+static MonoArray*
+ves_icall_MonoGenericInst_GetFields (MonoReflectionGenericInst *type,
+                                    MonoReflectionType *reflected_type)
+{
+       MonoGenericInst *ginst;
+       MonoDynamicGenericInst *dginst;
+       MonoDomain *domain;
+       MonoClass *refclass;
+       MonoArray *res;
+       int i;
+
+       MONO_ARCH_SAVE_REGS;
+
+       ginst = type->type.type->data.generic_inst;
+       g_assert ((dginst = ginst->dynamic_info) != NULL);
+
+       refclass = mono_class_from_mono_type (reflected_type->type);
+
+       domain = mono_object_domain (type);
+       res = mono_array_new (domain, mono_defaults.field_info_class, dginst->count_fields);
+
+       for (i = 0; i < dginst->count_fields; i++)
+               mono_array_set (res, gpointer, i,
+                               mono_field_get_object (domain, refclass, &dginst->fields [i]));
+
+       return res;
+}
+
+static MonoArray*
+ves_icall_MonoGenericInst_GetProperties (MonoReflectionGenericInst *type,
+                                        MonoReflectionType *reflected_type)
+{
+       static MonoClass *System_Reflection_PropertyInfo;
+       MonoGenericInst *ginst;
+       MonoDynamicGenericInst *dginst;
+       MonoDomain *domain;
+       MonoClass *refclass;
+       MonoArray *res;
+       int i;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (!System_Reflection_PropertyInfo)
+               System_Reflection_PropertyInfo = mono_class_from_name (
+                       mono_defaults.corlib, "System.Reflection", "PropertyInfo");
+
+       ginst = type->type.type->data.generic_inst;
+       g_assert ((dginst = ginst->dynamic_info) != NULL);
+
+       refclass = mono_class_from_mono_type (reflected_type->type);
+
+       domain = mono_object_domain (type);
+       res = mono_array_new (domain, System_Reflection_PropertyInfo, dginst->count_properties);
+
+       for (i = 0; i < dginst->count_properties; i++)
+               mono_array_set (res, gpointer, i,
+                               mono_property_get_object (domain, refclass, &dginst->properties [i]));
+
+       return res;
+}
+
+static MonoArray*
+ves_icall_MonoGenericInst_GetEvents (MonoReflectionGenericInst *type,
+                                    MonoReflectionType *reflected_type)
 {
-       guint32 index;
+       static MonoClass *System_Reflection_EventInfo;
+       MonoGenericInst *ginst;
+       MonoDynamicGenericInst *dginst;
+       MonoDomain *domain;
+       MonoClass *refclass;
+       MonoArray *res;
+       int i;
 
        MONO_ARCH_SAVE_REGS;
 
-       index = mono_array_length (mb->generic_params) - 1;
-       return mono_reflection_define_generic_parameter (NULL, mb, index, gparam);
+       if (!System_Reflection_EventInfo)
+               System_Reflection_EventInfo = mono_class_from_name (
+                       mono_defaults.corlib, "System.Reflection", "EventInfo");
+
+       ginst = type->type.type->data.generic_inst;
+       g_assert ((dginst = ginst->dynamic_info) != NULL);
+
+       refclass = mono_class_from_mono_type (reflected_type->type);
+
+       domain = mono_object_domain (type);
+       res = mono_array_new (domain, System_Reflection_EventInfo, dginst->count_events);
+
+       for (i = 0; i < dginst->count_events; i++)
+               mono_array_set (res, gpointer, i,
+                               mono_event_get_object (domain, refclass, &dginst->events [i]));
+
+       return res;
 }
 
 static MonoReflectionMethod *
@@ -1733,40 +1990,107 @@ ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType *type)
        return mono_method_get_object (mono_object_domain (type), method, klass);
 }
 
+static MonoReflectionMethod *
+ves_icall_MonoMethod_GetGenericMethodDefinition (MonoReflectionMethod *method)
+{
+       MonoMethodInflated *imethod;
+
+       MONO_ARCH_SAVE_REGS;
+
+       if (!method->method->signature->is_inflated) {
+               if (method->method->signature->generic_param_count)
+                       return method;
+
+               return NULL;
+       }
+
+       imethod = (MonoMethodInflated *) method->method;
+       if (imethod->context->gmethod && imethod->context->gmethod->reflection_info)
+               return imethod->context->gmethod->reflection_info;
+       else
+               return mono_method_get_object (
+                       mono_object_domain (method), imethod->declaring, NULL);
+}
+
 static gboolean
-ves_icall_MethodInfo_get_IsGenericMethodDefinition (MonoReflectionMethod *method)
+ves_icall_MonoMethod_get_HasGenericParameters (MonoReflectionMethod *method)
 {
-       MonoMethodNormal *mn;
        MONO_ARCH_SAVE_REGS;
 
        if ((method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
            (method->method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
                return FALSE;
 
-       mn = (MonoMethodNormal *) method->method;
-       return mn->header->gen_params != NULL;
+       return method->method->signature->generic_param_count != 0;
+}
+
+static gboolean
+ves_icall_MonoMethod_get_Mono_IsInflatedMethod (MonoReflectionMethod *method)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       if ((method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
+           (method->method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
+               return FALSE;
+
+       return method->method->signature->is_inflated;
+}
+
+static gboolean
+ves_icall_MonoMethod_get_IsGenericMethodDefinition (MonoReflectionMethod *method)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       if ((method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
+           (method->method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
+               return FALSE;
+
+       return method->method->signature->generic_param_count != 0;
 }
 
 static MonoArray*
 ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod *method)
 {
-       MonoMethodNormal *mn;
        MonoArray *res;
+       MonoDomain *domain;
+       MonoMethodNormal *mn;
        int count, i;
        MONO_ARCH_SAVE_REGS;
 
+       domain = mono_object_domain (method);
+
        if ((method->method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
            (method->method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
-               return mono_array_new (mono_object_domain (method), mono_defaults.monotype_class, 0);
+               return mono_array_new (domain, mono_defaults.monotype_class, 0);
+
+       if (method->method->signature->is_inflated) {
+               MonoMethodInflated *imethod = (MonoMethodInflated *) method->method;
+               MonoGenericMethod *gmethod = imethod->context->gmethod;
+
+               if (gmethod) {
+                       count = gmethod->mtype_argc;
+                       res = mono_array_new (domain, mono_defaults.monotype_class, count);
+
+                       for (i = 0; i < count; i++) {
+                               MonoType *t = gmethod->mtype_argv [i];
+                               mono_array_set (
+                                       res, gpointer, i, mono_type_get_object (domain, t));
+                       }
+
+                       return res;
+               }
+       }
 
        mn = (MonoMethodNormal *) method->method;
        count = method->method->signature->generic_param_count;
-       res = mono_array_new (mono_object_domain (method), mono_defaults.monotype_class, count);
+       res = mono_array_new (domain, mono_defaults.monotype_class, count);
 
        for (i = 0; i < count; i++) {
                MonoGenericParam *param = &mn->header->gen_params [i];
-               MonoClass *pklass = mono_class_from_generic_parameter (param, method->method->klass->image, TRUE);
-               mono_array_set (res, gpointer, i, mono_type_get_object (mono_object_domain (method), &pklass->byval_arg));
+               MonoClass *pklass = mono_class_from_generic_parameter (
+                       param, method->method->klass->image, TRUE);
+               mono_array_set (res, gpointer, i,
+                               mono_type_get_object (domain, &pklass->byval_arg));
        }
 
        return res;
@@ -1993,7 +2317,7 @@ ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
        MonoClass *enumc = mono_class_from_mono_type (type->type);
        guint i, j, nvalues, crow;
        MonoClassField *field;
-       
+
        MONO_ARCH_SAVE_REGS;
 
        info->utype = mono_type_get_object (domain, enumc->enum_basetype);
@@ -2003,33 +2327,42 @@ ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
        
        crow = -1;
        for (i = 0, j = 0; i < enumc->field.count; ++i) {
+               const char *p;
+               int len;
+
                field = &enumc->fields [i];
                if (strcmp ("value__", field->name) == 0)
                        continue;
+               if (mono_field_is_deleted (field))
+                       continue;
                mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
-               if (!field->data) {
+               if (!field->def_value) {
+                       field->def_value = g_new0 (MonoConstant, 1);
                        crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1), crow + 1);
+                       field->def_value->type = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_TYPE);
                        crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
-                       /* 1 is the length of the blob */
-                       field->data = 1 + mono_metadata_blob_heap (enumc->image, crow);
+                       field->def_value->value = (gpointer)mono_metadata_blob_heap (enumc->image, crow);
                }
+
+               p = field->def_value->value;
+               len = mono_metadata_decode_blob_size (p, &p);
                switch (enumc->enum_basetype->type) {
                case MONO_TYPE_U1:
                case MONO_TYPE_I1:
-                       mono_array_set (info->values, gchar, j, *field->data);
+                       mono_array_set (info->values, gchar, j, *p);
                        break;
                case MONO_TYPE_CHAR:
                case MONO_TYPE_U2:
                case MONO_TYPE_I2:
-                       mono_array_set (info->values, gint16, j, read16 (field->data));
+                       mono_array_set (info->values, gint16, j, read16 (p));
                        break;
                case MONO_TYPE_U4:
                case MONO_TYPE_I4:
-                       mono_array_set (info->values, gint32, j, read32 (field->data));
+                       mono_array_set (info->values, gint32, j, read32 (p));
                        break;
                case MONO_TYPE_U8:
                case MONO_TYPE_I8:
-                       mono_array_set (info->values, gint64, j, read64 (field->data));
+                       mono_array_set (info->values, gint64, j, read64 (p));
                        break;
                default:
                        g_error ("Implement type 0x%02x in get_enum_info", enumc->enum_basetype->type);
@@ -2045,6 +2378,7 @@ enum {
        BFLAGS_Static = 8,
        BFLAGS_Public = 0x10,
        BFLAGS_NonPublic = 0x20,
+       BFLAGS_FlattenHierarchy = 0x40,
        BFLAGS_InvokeMethod = 0x100,
        BFLAGS_CreateInstance = 0x200,
        BFLAGS_GetField = 0x400,
@@ -2076,6 +2410,8 @@ handle_parent:
        for (i = 0; i < klass->field.count; ++i) {
                match = 0;
                field = &klass->fields [i];
+               if (mono_field_is_deleted (field))
+                       continue;
                if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
                        if (bflags & BFLAGS_Public)
                                match++;
@@ -2088,7 +2424,8 @@ handle_parent:
                match = 0;
                if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
                        if (bflags & BFLAGS_Static)
-                               match++;
+                               if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+                                       match++;
                } else {
                        if (bflags & BFLAGS_Instance)
                                match++;
@@ -2105,7 +2442,7 @@ handle_parent:
                }
                g_free (utf8_name);
                
-               return mono_field_get_object (domain, klass, field);
+               return mono_field_get_object (domain, startklass, field);
        }
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
                goto handle_parent;
@@ -2114,11 +2451,11 @@ handle_parent:
 }
 
 static MonoArray*
-ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
+ves_icall_Type_GetFields_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype)
 {
        MonoDomain *domain; 
        GSList *l = NULL, *tmp;
-       MonoClass *startklass, *klass;
+       MonoClass *startklass, *klass, *refklass;
        MonoArray *res;
        MonoObject *member;
        int i, len, match;
@@ -2128,11 +2465,14 @@ ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
 
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
+       refklass = mono_class_from_mono_type (reftype->type);
 
 handle_parent: 
        for (i = 0; i < klass->field.count; ++i) {
                match = 0;
                field = &klass->fields [i];
+               if (mono_field_is_deleted (field))
+                       continue;
                if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
                        if (bflags & BFLAGS_Public)
                                match++;
@@ -2145,7 +2485,8 @@ handle_parent:
                match = 0;
                if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
                        if (bflags & BFLAGS_Static)
-                               match++;
+                               if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+                                       match++;
                } else {
                        if (bflags & BFLAGS_Instance)
                                match++;
@@ -2153,7 +2494,7 @@ handle_parent:
 
                if (!match)
                        continue;
-               member = (MonoObject*)mono_field_get_object (domain, klass, field);
+               member = (MonoObject*)mono_field_get_object (domain, refklass, field);
                l = g_slist_prepend (l, member);
        }
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
@@ -2169,22 +2510,29 @@ handle_parent:
 }
 
 static MonoArray*
-ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
+ves_icall_Type_GetMethodsByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype)
 {
        MonoDomain *domain; 
        GSList *l = NULL, *tmp;
-       MonoClass *startklass, *klass;
+       MonoClass *startklass, *klass, *refklass;
        MonoArray *res;
        MonoMethod *method;
        MonoObject *member;
        int i, len, match;
        GHashTable *method_slots = g_hash_table_new (NULL, NULL);
+       gchar *mname = NULL;
+       int (*compare_func) (const char *s1, const char *s2) = NULL;
                
        MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
+       refklass = mono_class_from_mono_type (reftype->type);
        len = 0;
+       if (name != NULL) {
+               mname = mono_string_to_utf8 (name);
+               compare_func = (ignore_case) ? g_strcasecmp : strcmp;
+       }
 
 handle_parent:
        for (i = 0; i < klass->method.count; ++i) {
@@ -2204,7 +2552,8 @@ handle_parent:
                match = 0;
                if (method->flags & METHOD_ATTRIBUTE_STATIC) {
                        if (bflags & BFLAGS_Static)
-                               match++;
+                               if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+                                       match++;
                } else {
                        if (bflags & BFLAGS_Instance)
                                match++;
@@ -2212,17 +2561,28 @@ handle_parent:
 
                if (!match)
                        continue;
+
+               if (name != NULL) {
+                       if (compare_func (mname, method->name))
+                               continue;
+               }
+               
                match = 0;
-               if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
-                       continue;
-               g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
-               member = (MonoObject*)mono_method_get_object (domain, method, startklass);
+               if (method->slot != -1) {
+                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
+                               continue;
+                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
+               }
+               
+               member = (MonoObject*)mono_method_get_object (domain, method, refklass);
                
                l = g_slist_prepend (l, member);
                len++;
        }
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
                goto handle_parent;
+
+       g_free (mname);
        res = mono_array_new (domain, mono_defaults.method_info_class, len);
        i = 0;
 
@@ -2236,12 +2596,12 @@ handle_parent:
 }
 
 static MonoArray*
-ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
+ves_icall_Type_GetConstructors_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype)
 {
        MonoDomain *domain; 
        GSList *l = NULL, *tmp;
        static MonoClass *System_Reflection_ConstructorInfo;
-       MonoClass *startklass, *klass;
+       MonoClass *startklass, *klass, *refklass;
        MonoArray *res;
        MonoMethod *method;
        MonoObject *member;
@@ -2251,6 +2611,7 @@ ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
 
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
+       refklass = mono_class_from_mono_type (reftype->type);
 
        for (i = 0; i < klass->method.count; ++i) {
                match = 0;
@@ -2269,7 +2630,8 @@ ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
                match = 0;
                if (method->flags & METHOD_ATTRIBUTE_STATIC) {
                        if (bflags & BFLAGS_Static)
-                               match++;
+                               if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+                                       match++;
                } else {
                        if (bflags & BFLAGS_Instance)
                                match++;
@@ -2277,7 +2639,7 @@ ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
 
                if (!match)
                        continue;
-               member = (MonoObject*)mono_method_get_object (domain, method, startklass);
+               member = (MonoObject*)mono_method_get_object (domain, method, refklass);
                        
                l = g_slist_prepend (l, member);
        }
@@ -2295,7 +2657,7 @@ ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
 }
 
 static MonoArray*
-ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
+ves_icall_Type_GetPropertiesByName (MonoReflectionType *type, MonoString *name, guint32 bflags, MonoBoolean ignore_case, MonoReflectionType *reftype)
 {
        MonoDomain *domain; 
        GSList *l = NULL, *tmp;
@@ -2307,11 +2669,17 @@ ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
        int i, match;
        int len = 0;
        GHashTable *method_slots = g_hash_table_new (NULL, NULL);
+       gchar *propname = NULL;
+       int (*compare_func) (const char *s1, const char *s2) = NULL;
 
        MONO_ARCH_SAVE_REGS;
 
        domain = ((MonoObject *)type)->vtable->domain;
        klass = startklass = mono_class_from_mono_type (type->type);
+       if (name != NULL) {
+               propname = mono_string_to_utf8 (name);
+               compare_func = (ignore_case) ? g_strcasecmp : strcmp;
+       }
 
 handle_parent:
        for (i = 0; i < klass->property.count; ++i) {
@@ -2332,7 +2700,8 @@ handle_parent:
                match = 0;
                if (method->flags & METHOD_ATTRIBUTE_STATIC) {
                        if (bflags & BFLAGS_Static)
-                               match++;
+                               if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+                                       match++;
                } else {
                        if (bflags & BFLAGS_Instance)
                                match++;
@@ -2342,15 +2711,24 @@ handle_parent:
                        continue;
                match = 0;
 
-               if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
-                       continue;
-               g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), prop);
+               if (name != NULL) {
+                       if (compare_func (propname, prop->name))
+                               continue;
+               }
+               
+               if (method->slot != -1) {
+                       if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
+                               continue;
+                       g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), prop);
+               }
 
-               l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
+               l = g_slist_prepend (l, mono_property_get_object (domain, startklass, prop));
                len++;
        }
        if ((!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
                goto handle_parent;
+
+       g_free (propname);
        if (!System_Reflection_PropertyInfo)
                System_Reflection_PropertyInfo = mono_class_from_name (
                        mono_defaults.corlib, "System.Reflection", "PropertyInfo");
@@ -2370,7 +2748,7 @@ static MonoReflectionEvent *
 ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32 bflags)
 {
        MonoDomain *domain;
-       MonoClass *klass;
+       MonoClass *klass, *startklass;
        gint i;
        MonoEvent *event;
        MonoMethod *method;
@@ -2379,7 +2757,7 @@ ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32
        MONO_ARCH_SAVE_REGS;
 
        event_name = mono_string_to_utf8 (name);
-       klass = mono_class_from_mono_type (type->type);
+       klass = startklass = mono_class_from_mono_type (type->type);
        domain = mono_object_domain (type);
 
 handle_parent: 
@@ -2401,7 +2779,7 @@ handle_parent:
                }
 
                g_free (event_name);
-               return mono_event_get_object (domain, klass, event);
+               return mono_event_get_object (domain, startklass, event);
        }
 
        if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
@@ -2412,7 +2790,7 @@ handle_parent:
 }
 
 static MonoArray*
-ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
+ves_icall_Type_GetEvents_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype)
 {
        MonoDomain *domain; 
        GSList *l = NULL, *tmp;
@@ -2447,7 +2825,8 @@ handle_parent:
                match = 0;
                if (method->flags & METHOD_ATTRIBUTE_STATIC) {
                        if (bflags & BFLAGS_Static)
-                               match++;
+                               if ((bflags & BFLAGS_FlattenHierarchy) || (klass == startklass))
+                                       match++;
                } else {
                        if (bflags & BFLAGS_Instance)
                                match++;
@@ -2589,9 +2968,8 @@ ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *as
                        MonoReflectionAssemblyBuilder *abuilder = (MonoReflectionAssemblyBuilder*)assembly;
                        int i;
 
-                       if (!abuilder->modules)
-                               type = NULL;
-                       else {
+                       type = NULL;
+                       if (abuilder->modules) {
                                for (i = 0; i < mono_array_length (abuilder->modules); ++i) {
                                        MonoReflectionModuleBuilder *mb = mono_array_get (abuilder->modules, MonoReflectionModuleBuilder*, i);
                                        type = mono_reflection_get_type (&mb->dynamic_image->image, &info, ignoreCase);
@@ -2599,6 +2977,15 @@ ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *as
                                                break;
                                }
                        }
+
+                       if (!type && abuilder->loaded_modules) {
+                               for (i = 0; i < mono_array_length (abuilder->loaded_modules); ++i) {
+                                       MonoReflectionModule *mod = mono_array_get (abuilder->loaded_modules, MonoReflectionModule*, i);
+                                       type = mono_reflection_get_type (mod->image, &info, ignoreCase);
+                                       if (type)
+                                               break;
+                               }
+                       }
                }
                else
                        type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
@@ -2811,13 +3198,15 @@ g_concat_dir_and_file (const char *dir, const char *file)
 }
 
 static void *
-ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name, gint32 *size) 
+ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name, gint32 *size, MonoReflectionModule **ref_module
 {
        char *n = mono_string_to_utf8 (name);
        MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
        guint32 i;
        guint32 cols [MONO_MANIFEST_SIZE];
+       guint32 impl, file_idx;
        const char *val;
+       MonoImage *module;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -2831,16 +3220,25 @@ ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflection
        if (i == table->rows)
                return NULL;
        /* FIXME */
-       if (cols [MONO_MANIFEST_IMPLEMENTATION]) {
+       impl = cols [MONO_MANIFEST_IMPLEMENTATION];
+       if (impl) {
                /*
                 * this code should only be called after obtaining the 
                 * ResourceInfo and handling the other cases.
                 */
-               g_assert_not_reached ();
-               return NULL;
+               g_assert ((impl & IMPLEMENTATION_MASK) == IMPLEMENTATION_FILE);
+               file_idx = impl >> IMPLEMENTATION_BITS;
+
+               module = mono_image_load_file_for_image (assembly->assembly->image, file_idx);
+               if (!module)
+                       return NULL;
        }
+       else
+               module = assembly->assembly->image;
 
-       return (void*)mono_image_get_resource (assembly->assembly->image, cols [MONO_MANIFEST_OFFSET], size);
+       *ref_module = mono_module_get_object (mono_domain_get (), module);
+
+       return (void*)mono_image_get_resource (module, cols [MONO_MANIFEST_OFFSET], size);
 }
 
 static gboolean
@@ -3251,6 +3649,13 @@ ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule *module)
        return mono_type_get_object (domain, &klass->byval_arg);
 }
 
+static void
+ves_icall_System_Reflection_Module_Close (MonoReflectionModule *module)
+{
+       if (module->image)
+               mono_image_close (module->image);
+}
+
 static MonoString*
 ves_icall_System_Reflection_Module_GetGuidInternal (MonoReflectionModule *module)
 {
@@ -3347,21 +3752,46 @@ ves_icall_Type_IsArrayImpl (MonoReflectionType *t)
        return res;
 }
 
-static MonoObject *
-ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target,
-                                                  MonoReflectionMethod *info)
+static MonoReflectionType *
+ves_icall_Type_make_array_type (MonoReflectionType *type, int rank)
 {
-       MonoClass *delegate_class = mono_class_from_mono_type (type->type);
-       MonoObject *delegate;
-       gpointer func;
+       MonoClass *klass, *aklass;
 
        MONO_ARCH_SAVE_REGS;
 
-       mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
-
-       delegate = mono_object_new (mono_object_domain (type), delegate_class);
+       klass = mono_class_from_mono_type (type->type);
+       aklass = mono_array_class_get (klass, rank);
 
-       func = mono_compile_method (info->method);
+       return mono_type_get_object (mono_object_domain (type), &aklass->byval_arg);
+}
+
+static MonoReflectionType *
+ves_icall_Type_make_byref_type (MonoReflectionType *type)
+{
+       MonoClass *klass;
+
+       MONO_ARCH_SAVE_REGS;
+
+       klass = mono_class_from_mono_type (type->type);
+
+       return mono_type_get_object (mono_object_domain (type), &klass->this_arg);
+}
+
+static MonoObject *
+ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target,
+                                                  MonoReflectionMethod *info)
+{
+       MonoClass *delegate_class = mono_class_from_mono_type (type->type);
+       MonoObject *delegate;
+       gpointer func;
+
+       MONO_ARCH_SAVE_REGS;
+
+       mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
+
+       delegate = mono_object_new (mono_object_domain (type), delegate_class);
+
+       func = mono_compile_method (info->method);
 
        mono_delegate_ctor (delegate, target, func);
 
@@ -3695,32 +4125,37 @@ ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, Mo
 }
 
 static MonoObject *
-ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
+ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this, MonoString *class_name)
 {
        MonoDomain *domain = mono_object_domain (this); 
        MonoObject *res;
        MonoRealProxy *rp = ((MonoRealProxy *)this);
+       MonoTransparentProxy *tp;
        MonoType *type;
        MonoClass *klass;
 
        MONO_ARCH_SAVE_REGS;
 
        res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
+       tp = (MonoTransparentProxy*) res;
        
-       ((MonoTransparentProxy *)res)->rp = rp;
+       tp->rp = rp;
        type = ((MonoReflectionType *)rp->class_to_proxy)->type;
        klass = mono_class_from_mono_type (type);
 
-       if (klass->flags & TYPE_ATTRIBUTE_INTERFACE)
-               ((MonoTransparentProxy *)res)->klass = mono_defaults.marshalbyrefobject_class;
-       else
-               ((MonoTransparentProxy *)res)->klass = klass;
-
-       res->vtable = mono_class_proxy_vtable (domain, klass);
+       tp->custom_type_info = (mono_object_isinst (this, mono_defaults.iremotingtypeinfo_class) != NULL);
+       tp->remote_class = mono_remote_class (domain, class_name, klass);
+       res->vtable = tp->remote_class->vtable;
 
        return res;
 }
 
+static MonoReflectionType *
+ves_icall_Remoting_RealProxy_InternalGetProxyType (MonoTransparentProxy *tp)
+{
+       return mono_type_get_object (mono_object_domain (tp), &tp->remote_class->proxy_class->byval_arg);
+}
+
 /* System.Environment */
 
 static MonoString *
@@ -3883,6 +4318,12 @@ ves_icall_System_Environment_Exit (int result)
        exit (result);
 }
 
+static MonoString*
+ves_icall_System_Environment_GetGacPath (void)
+{
+       return mono_string_new (mono_domain_get (), MONO_ASSEMBLIES);
+}
+
 static MonoString*
 ves_icall_System_Text_Encoding_InternalCodePage (void) 
 {
@@ -3902,6 +4343,18 @@ ves_icall_System_Text_Encoding_InternalCodePage (void)
        return mono_string_new (mono_domain_get (), cset);
 }
 
+static MonoBoolean
+ves_icall_System_Environment_get_HasShutdownStarted (void)
+{
+       if (mono_runtime_is_shutting_down ())
+               return TRUE;
+
+       if (mono_domain_is_unloading (mono_domain_get ()))
+               return TRUE;
+
+       return FALSE;
+}
+
 static void
 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this, 
                                         MonoReflectionMethod *method,
@@ -4116,13 +4569,16 @@ ves_icall_MonoMethod_get_base_definition (MonoReflectionMethod *m)
        MONO_ARCH_SAVE_REGS;
 
        if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
-            method->klass->flags & TYPE_ATTRIBUTE_INTERFACE ||
-            method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
+           MONO_CLASS_IS_INTERFACE (method->klass) ||
+           method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
                return m;
 
        if (method->klass == NULL || (klass = method->klass->parent) == NULL)
                return m;
 
+       if (klass->generic_inst)
+               klass = mono_class_from_mono_type (klass->generic_inst->generic_type);
+
        while (result == NULL && klass != NULL && (klass->vtable_size > method->slot))
        {
                result = klass->vtable [method->slot];
@@ -4248,9 +4704,14 @@ mono_TypedReference_ToObject (MonoTypedRef tref)
 static void
 prelink_method (MonoMethod *method)
 {
+       const char *exc_class, *exc_arg;
        if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
                return;
-       mono_lookup_pinvoke_call (method);
+       mono_lookup_pinvoke_call (method, &exc_class, &exc_arg);
+       if (exc_class) {
+               mono_raise_exception( 
+                       mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg ) );
+       }
        /* create the wrapper, too? */
 }
 
@@ -4273,722 +4734,997 @@ ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType
                prelink_method (klass->methods [i]);
 }
 
+static void
+ves_icall_System_Char_GetDataTablePointers (guint8 **category_data, guint8 **numeric_data,
+               gdouble **numeric_data_values, guint16 **to_lower_data_low,
+               guint16 **to_lower_data_high, guint16 **to_upper_data_low,
+               guint16 **to_upper_data_high)
+{
+       *category_data = CategoryData;
+       *numeric_data = NumericData;
+       *numeric_data_values = NumericDataValues;
+       *to_lower_data_low = ToLowerDataLow;
+       *to_lower_data_high = ToLowerDataHigh;
+       *to_upper_data_low = ToUpperDataLow;
+       *to_upper_data_high = ToUpperDataHigh;
+}
+
 /* icall map */
+typedef struct {
+       const char *method;
+       gconstpointer func;
+} IcallEntry;
 
-static gconstpointer icall_map [] = {
-       /*
-        * System.Array
-        */
-       "System.Array::GetValue",         ves_icall_System_Array_GetValue,
-       "System.Array::SetValue",         ves_icall_System_Array_SetValue,
-       "System.Array::GetValueImpl",     ves_icall_System_Array_GetValueImpl,
-       "System.Array::SetValueImpl",     ves_icall_System_Array_SetValueImpl,
-       "System.Array::GetRank",          ves_icall_System_Array_GetRank,
-       "System.Array::GetLength",        ves_icall_System_Array_GetLength,
-       "System.Array::GetLowerBound",    ves_icall_System_Array_GetLowerBound,
-       "System.Array::CreateInstanceImpl",   ves_icall_System_Array_CreateInstanceImpl,
-       "System.Array::FastCopy",         ves_icall_System_Array_FastCopy,
-       "System.Array::Clone",            mono_array_clone,
+typedef struct {
+       const char *klass;
+       const IcallEntry *icalls;
+       const int size;
+} IcallMap;
 
-       /*
-        * System.ArgIterator
-        */
-       "System.ArgIterator::Setup",                            mono_ArgIterator_Setup,
-       "System.ArgIterator::IntGetNextArg()",                  mono_ArgIterator_IntGetNextArg,
-       "System.ArgIterator::IntGetNextArg(intptr)", mono_ArgIterator_IntGetNextArgT,
-       "System.ArgIterator::IntGetNextArgType",                mono_ArgIterator_IntGetNextArgType,
+static const IcallEntry activator_icalls [] = {
+       {"CreateInstanceInternal", ves_icall_System_Activator_CreateInstanceInternal}
+};
+static const IcallEntry appdomain_icalls [] = {
+       {"ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly},
+       {"GetAssemblies", ves_icall_System_AppDomain_GetAssemblies},
+       {"GetData", ves_icall_System_AppDomain_GetData},
+       {"InternalGetContext", ves_icall_System_AppDomain_InternalGetContext},
+       {"InternalGetDefaultContext", ves_icall_System_AppDomain_InternalGetDefaultContext},
+       {"InternalGetProcessGuid", ves_icall_System_AppDomain_InternalGetProcessGuid},
+       {"InternalIsFinalizingForUnload", ves_icall_System_AppDomain_InternalIsFinalizingForUnload},
+       {"InternalPopDomainRef", ves_icall_System_AppDomain_InternalPopDomainRef},
+       {"InternalPushDomainRef", ves_icall_System_AppDomain_InternalPushDomainRef},
+       {"InternalPushDomainRefByID", ves_icall_System_AppDomain_InternalPushDomainRefByID},
+       {"InternalSetContext", ves_icall_System_AppDomain_InternalSetContext},
+       {"InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain},
+       {"InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID},
+       {"InternalUnload", ves_icall_System_AppDomain_InternalUnload},
+       {"LoadAssembly", ves_icall_System_AppDomain_LoadAssembly},
+       {"LoadAssemblyRaw", ves_icall_System_AppDomain_LoadAssemblyRaw},
+       {"SetData", ves_icall_System_AppDomain_SetData},
+       {"createDomain", ves_icall_System_AppDomain_createDomain},
+       {"getCurDomain", ves_icall_System_AppDomain_getCurDomain},
+       {"getFriendlyName", ves_icall_System_AppDomain_getFriendlyName},
+       {"getSetup", ves_icall_System_AppDomain_getSetup}
+};
 
-       /*
-        * System.TypedReference
-        */
-       "System.TypedReference::ToObject",                      mono_TypedReference_ToObject,
+static const IcallEntry appdomainsetup_icalls [] = {
+       {"InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup}
+};
 
-       /*
-        * System.Object
-        */
-       "System.Object::MemberwiseClone", ves_icall_System_Object_MemberwiseClone,
-       "System.Object::GetType", ves_icall_System_Object_GetType,
-       "System.Object::InternalGetHashCode", ves_icall_System_Object_GetHashCode,
-       "System.Object::obj_address", ves_icall_System_Object_obj_address,
+static const IcallEntry argiterator_icalls [] = {
+       {"IntGetNextArg()",                  mono_ArgIterator_IntGetNextArg},
+       {"IntGetNextArg(intptr)", mono_ArgIterator_IntGetNextArgT},
+       {"IntGetNextArgType",                mono_ArgIterator_IntGetNextArgType},
+       {"Setup",                            mono_ArgIterator_Setup}
+};
 
-       /*
-        * System.ValueType
-        */
-       "System.ValueType::InternalGetHashCode", ves_icall_System_ValueType_InternalGetHashCode,
-       "System.ValueType::InternalEquals", ves_icall_System_ValueType_Equals,
+static const IcallEntry array_icalls [] = {
+       {"Clone",            mono_array_clone},
+       {"CreateInstanceImpl",   ves_icall_System_Array_CreateInstanceImpl},
+       {"FastCopy",         ves_icall_System_Array_FastCopy},
+       {"GetLength",        ves_icall_System_Array_GetLength},
+       {"GetLowerBound",    ves_icall_System_Array_GetLowerBound},
+       {"GetRank",          ves_icall_System_Array_GetRank},
+       {"GetValue",         ves_icall_System_Array_GetValue},
+       {"GetValueImpl",     ves_icall_System_Array_GetValueImpl},
+       {"SetValue",         ves_icall_System_Array_SetValue},
+       {"SetValueImpl",     ves_icall_System_Array_SetValueImpl}
+};
 
-       /*
-        * System.String
-        */
-       
-       "System.String::.ctor(char*)", ves_icall_System_String_ctor_charp,
-       "System.String::.ctor(char*,int,int)", ves_icall_System_String_ctor_charp_int_int,
-       "System.String::.ctor(sbyte*)", ves_icall_System_String_ctor_sbytep,
-       "System.String::.ctor(sbyte*,int,int)", ves_icall_System_String_ctor_sbytep_int_int,
-       "System.String::.ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding,
-       "System.String::.ctor(char[])", ves_icall_System_String_ctor_chara,
-       "System.String::.ctor(char[],int,int)", ves_icall_System_String_ctor_chara_int_int,
-       "System.String::.ctor(char,int)", ves_icall_System_String_ctor_char_int,
-       "System.String::InternalJoin", ves_icall_System_String_InternalJoin,
-       "System.String::InternalInsert", ves_icall_System_String_InternalInsert,
-       "System.String::InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char,
-       "System.String::InternalRemove", ves_icall_System_String_InternalRemove,
-       "System.String::InternalCopyTo", ves_icall_System_String_InternalCopyTo,
-       "System.String::InternalSplit", ves_icall_System_String_InternalSplit,
-       "System.String::InternalTrim", ves_icall_System_String_InternalTrim,
-       "System.String::InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny,
-       "System.String::InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny,
-       "System.String::InternalPad", ves_icall_System_String_InternalPad,
-       "System.String::InternalAllocateStr", ves_icall_System_String_InternalAllocateStr,
-       "System.String::InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str,
-       "System.String::InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN,
-       "System.String::InternalIntern", ves_icall_System_String_InternalIntern,
-       "System.String::InternalIsInterned", ves_icall_System_String_InternalIsInterned,
-       "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
-       "System.String::get_Chars", ves_icall_System_String_get_Chars,
+static const IcallEntry buffer_icalls [] = {
+       {"BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal},
+       {"ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal},
+       {"GetByteInternal", ves_icall_System_Buffer_GetByteInternal},
+       {"SetByteInternal", ves_icall_System_Buffer_SetByteInternal}
+};
 
-       /*
-        * System.AppDomain
-        */
-       "System.AppDomain::createDomain", ves_icall_System_AppDomain_createDomain,
-       "System.AppDomain::getCurDomain", ves_icall_System_AppDomain_getCurDomain,
-       "System.AppDomain::GetData", ves_icall_System_AppDomain_GetData,
-       "System.AppDomain::SetData", ves_icall_System_AppDomain_SetData,
-       "System.AppDomain::getSetup", ves_icall_System_AppDomain_getSetup,
-       "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
-       "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
-       "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
-       "System.AppDomain::LoadAssemblyRaw", ves_icall_System_AppDomain_LoadAssemblyRaw,
-       "System.AppDomain::InternalIsFinalizingForUnload", ves_icall_System_AppDomain_InternalIsFinalizingForUnload,
-       "System.AppDomain::InternalUnload", ves_icall_System_AppDomain_InternalUnload,
-       "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
-       "System.AppDomain::InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain,
-       "System.AppDomain::InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID,
-       "System.AppDomain::InternalPushDomainRef", ves_icall_System_AppDomain_InternalPushDomainRef,
-       "System.AppDomain::InternalPushDomainRefByID", ves_icall_System_AppDomain_InternalPushDomainRefByID,
-       "System.AppDomain::InternalPopDomainRef", ves_icall_System_AppDomain_InternalPopDomainRef,
-       "System.AppDomain::InternalSetContext", ves_icall_System_AppDomain_InternalSetContext,
-       "System.AppDomain::InternalGetContext", ves_icall_System_AppDomain_InternalGetContext,
-       "System.AppDomain::InternalGetDefaultContext", ves_icall_System_AppDomain_InternalGetDefaultContext,
-       "System.AppDomain::InternalGetProcessGuid", ves_icall_System_AppDomain_InternalGetProcessGuid,
+static const IcallEntry char_icalls [] = {
+       {"GetDataTablePointers", ves_icall_System_Char_GetDataTablePointers},
+};
 
-       /*
-        * System.AppDomainSetup
-        */
-       "System.AppDomainSetup::InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup,
+static const IcallEntry defaultconf_icalls [] = {
+       {"get_machine_config_path", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path}
+};
 
-       /*
-        * System.Double
-        */
-       "System.Double::ParseImpl",    mono_double_ParseImpl,
-       "System.Double::AssertEndianity", ves_icall_System_Double_AssertEndianity,
+static const IcallEntry timezone_icalls [] = {
+       {"GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData}
+};
 
-       /*
-        * System.Decimal
-        */
-       "System.Decimal::decimal2UInt64", mono_decimal2UInt64,
-       "System.Decimal::decimal2Int64", mono_decimal2Int64,
-       "System.Decimal::double2decimal", mono_double2decimal, /* FIXME: wrong signature. */
-       "System.Decimal::decimalIncr", mono_decimalIncr,
-       "System.Decimal::decimalSetExponent", mono_decimalSetExponent,
-       "System.Decimal::decimal2double", mono_decimal2double,
-       "System.Decimal::decimalFloorAndTrunc", mono_decimalFloorAndTrunc,
-       "System.Decimal::decimalRound", mono_decimalRound,
-       "System.Decimal::decimalMult", mono_decimalMult,
-       "System.Decimal::decimalDiv", mono_decimalDiv,
-       "System.Decimal::decimalIntDiv", mono_decimalIntDiv,
-       "System.Decimal::decimalCompare", mono_decimalCompare,
-       "System.Decimal::string2decimal", mono_string2decimal,
-       "System.Decimal::decimal2string", mono_decimal2string,
+static const IcallEntry datetime_icalls [] = {
+       {"GetNow", ves_icall_System_DateTime_GetNow}
+};
 
-       /*
-        * ModuleBuilder
-        */
-       "System.Reflection.Emit.ModuleBuilder::getUSIndex", mono_image_insert_string,
-       "System.Reflection.Emit.ModuleBuilder::getToken", ves_icall_ModuleBuilder_getToken,
-       "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
-       "System.Reflection.Emit.ModuleBuilder::basic_init", mono_image_module_basic_init,
-       "System.Reflection.Emit.ModuleBuilder::build_metadata", ves_icall_ModuleBuilder_build_metadata,
-       "System.Reflection.Emit.ModuleBuilder::getDataChunk", ves_icall_ModuleBuilder_getDataChunk,
-       
-       /*
-        * AssemblyBuilder
-        */
-       "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
+static const IcallEntry decimal_icalls [] = {
+       {"decimal2Int64", mono_decimal2Int64},
+       {"decimal2UInt64", mono_decimal2UInt64},
+       {"decimal2double", mono_decimal2double},
+       {"decimal2string", mono_decimal2string},
+       {"decimalCompare", mono_decimalCompare},
+       {"decimalDiv", mono_decimalDiv},
+       {"decimalFloorAndTrunc", mono_decimalFloorAndTrunc},
+       {"decimalIncr", mono_decimalIncr},
+       {"decimalIntDiv", mono_decimalIntDiv},
+       {"decimalMult", mono_decimalMult},
+       {"decimalRound", mono_decimalRound},
+       {"decimalSetExponent", mono_decimalSetExponent},
+       {"double2decimal", mono_double2decimal}, /* FIXME: wrong signature. */
+       {"string2decimal", mono_string2decimal}
+};
 
-       /*
-        * Reflection stuff.
-        */
-       "System.Reflection.MonoMethodInfo::get_method_info", ves_icall_get_method_info,
-       "System.Reflection.MonoMethodInfo::get_parameter_info", ves_icall_get_parameter_info,
-       "System.Reflection.MonoPropertyInfo::get_property_info", ves_icall_get_property_info,
-       "System.Reflection.MonoEventInfo::get_event_info", ves_icall_get_event_info,
-       "System.Reflection.MonoMethod::InternalInvoke", ves_icall_InternalInvoke,
-       "System.Reflection.MonoCMethod::InternalInvoke", ves_icall_InternalInvoke,
-       "System.Reflection.MethodBase::GetCurrentMethod", ves_icall_GetCurrentMethod,
-       "System.MonoCustomAttrs::GetCustomAttributes", mono_reflection_get_custom_attrs,
-       "System.Reflection.Emit.CustomAttributeBuilder::GetBlob", mono_reflection_get_custom_attrs_blob,
-       "System.Reflection.MonoField::GetParentType", ves_icall_MonoField_GetParentType,
-       "System.Reflection.MonoField::GetValueInternal", ves_icall_MonoField_GetValueInternal,
-       "System.Reflection.MonoField::SetValueInternal", ves_icall_FieldInfo_SetValueInternal,
-       "System.Reflection.Emit.SignatureHelper::get_signature_local", mono_reflection_sighelper_get_signature_local,
-       "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
-
-       "System.RuntimeMethodHandle::GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer,
-       "System.Reflection.MonoMethod::get_base_definition", ves_icall_MonoMethod_get_base_definition,
-       
-       /* System.Enum */
+static const IcallEntry delegate_icalls [] = {
+       {"CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal}
+};
 
-       "System.MonoEnumInfo::get_enum_info", ves_icall_get_enum_info,
-       "System.Enum::get_value", ves_icall_System_Enum_get_value,
-       "System.Enum::ToObject", ves_icall_System_Enum_ToObject,
+static const IcallEntry tracelist_icalls [] = {
+       {"WriteWindowsDebugString", ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString}
+};
 
-       /*
-        * TypeBuilder
-        */
-       "System.Reflection.Emit.TypeBuilder::setup_internal_class", mono_reflection_setup_internal_class,
-       "System.Reflection.Emit.TypeBuilder::create_internal_class", mono_reflection_create_internal_class,
-       "System.Reflection.Emit.TypeBuilder::create_runtime_class", mono_reflection_create_runtime_class,
-       "System.Reflection.Emit.TypeBuilder::setup_generic_class", mono_reflection_setup_generic_class,
+static const IcallEntry fileversion_icalls [] = {
+       {"GetVersionInfo_internal(string)", ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal}
+};
 
-       /*
-        * DynamicMethod
-        */
-       "System.Reflection.Emit.DynamicMethod::create_dynamic_method", mono_reflection_create_dynamic_method,
+static const IcallEntry process_icalls [] = {
+       {"ExitCode_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitCode_internal},
+       {"ExitTime_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitTime_internal},
+       {"GetModules_internal()", ves_icall_System_Diagnostics_Process_GetModules_internal},
+       {"GetPid_internal()", ves_icall_System_Diagnostics_Process_GetPid_internal},
+       {"GetProcess_internal(int)", ves_icall_System_Diagnostics_Process_GetProcess_internal},
+       {"GetProcesses_internal()", ves_icall_System_Diagnostics_Process_GetProcesses_internal},
+       {"GetWorkingSet_internal(intptr,int&,int&)", ves_icall_System_Diagnostics_Process_GetWorkingSet_internal},
+       {"Kill_internal", ves_icall_System_Diagnostics_Process_Kill_internal},
+       {"ProcessName_internal(intptr)", ves_icall_System_Diagnostics_Process_ProcessName_internal},
+       {"Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal},
+       {"SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal},
+       {"StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal},
+       {"Start_internal(string,string,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal},
+       {"WaitForExit_internal(intptr,int)", ves_icall_System_Diagnostics_Process_WaitForExit_internal}
+};
 
-       /*
-        * TypeBuilder generics icalls.
-        */
-       "System.Reflection.Emit.TypeBuilder::get_IsGenericParameter", ves_icall_TypeBuilder_get_IsGenericParameter,
-       "System.Reflection.Emit.TypeBuilder::define_generic_parameter", ves_icall_TypeBuilder_define_generic_parameter,
-       
-       /*
-        * MethodBuilder generic icalls.
-        */
-       "System.Reflection.Emit.MethodBuilder::define_generic_parameter", ves_icall_MethodBuilder_define_generic_parameter,
+static const IcallEntry double_icalls [] = {
+       {"AssertEndianity", ves_icall_System_Double_AssertEndianity},
+       {"ParseImpl",    mono_double_ParseImpl}
+};
 
-       /*
-        * MonoGenericInst generic icalls.
-        */
-       "System.Reflection.MonoGenericInst::inflate_method", mono_reflection_inflate_method_or_ctor,
-       "System.Reflection.MonoGenericInst::inflate_ctor", mono_reflection_inflate_method_or_ctor,
-       "System.Reflection.MonoGenericInst::inflate_field", mono_reflection_inflate_field,
-       
-       /*
-        * System.Type
-        */
-       "System.Type::internal_from_name", ves_icall_type_from_name,
-       "System.Type::internal_from_handle", ves_icall_type_from_handle,
-       "System.MonoType::get_attributes", ves_icall_get_attributes,
-       "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
-       "System.Type::type_is_assignable_from", ves_icall_type_is_assignable_from,
-       "System.Type::Equals", ves_icall_type_Equals,
-       "System.Type::GetTypeCode", ves_icall_type_GetTypeCode,
-       "System.Type::GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData,
-       "System.Type::IsArrayImpl", ves_icall_Type_IsArrayImpl,
-
-       /* Type generics icalls */
-       "System.Type::GetGenericArguments", ves_icall_Type_GetGenericArguments,
-       "System.Type::GetGenericParameterPosition", ves_icall_Type_GetGenericParameterPosition,
-       "System.Type::get_IsGenericTypeDefinition", ves_icall_Type_get_IsGenericTypeDefinition,
-       "System.Type::GetGenericTypeDefinition_impl", ves_icall_Type_GetGenericTypeDefinition_impl,
-       "System.Type::BindGenericParameters", ves_icall_Type_BindGenericParameters,
-       "System.Type::get_IsGenericInstance", ves_icall_Type_get_IsGenericInstance,
-       
-       "System.MonoType::get_HasGenericArguments", ves_icall_MonoType_get_HasGenericArguments,
-       "System.MonoType::get_IsGenericParameter", ves_icall_MonoType_get_IsGenericParameter,
-       "System.MonoType::get_DeclaringMethod", ves_icall_MonoType_get_DeclaringMethod,
+static const IcallEntry enum_icalls [] = {
+       {"ToObject", ves_icall_System_Enum_ToObject},
+       {"get_value", ves_icall_System_Enum_get_value}
+};
 
-       /* Method generics icalls */
-       "System.Reflection.MethodInfo::get_IsGenericMethodDefinition", ves_icall_MethodInfo_get_IsGenericMethodDefinition,
-       "System.Reflection.MethodInfo::BindGenericParameters", mono_reflection_bind_generic_method_parameters,
-       "System.Reflection.MonoMethod::GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments,
+static const IcallEntry environment_icalls [] = {
+       {"Exit", ves_icall_System_Environment_Exit},
+       {"GetCommandLineArgs", mono_runtime_get_main_args},
+       {"GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable},
+       {"GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames},
+       {"GetMachineConfigPath",        ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+       {"get_ExitCode", mono_environment_exitcode_get},
+       {"get_HasShutdownStarted", ves_icall_System_Environment_get_HasShutdownStarted},
+       {"get_MachineName", ves_icall_System_Environment_get_MachineName},
+       {"get_NewLine", ves_icall_System_Environment_get_NewLine},
+       {"get_Platform", ves_icall_System_Environment_get_Platform},
+       {"get_TickCount", ves_icall_System_Environment_get_TickCount},
+       {"get_UserName", ves_icall_System_Environment_get_UserName},
+       {"internalGetGacPath", ves_icall_System_Environment_GetGacPath},
+       {"set_ExitCode", mono_environment_exitcode_set}
+};
 
+static const IcallEntry cultureinfo_icalls [] = {
+       {"construct_compareinfo(object,string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo},
+       {"construct_datetime_format", ves_icall_System_Globalization_CultureInfo_construct_datetime_format},
+       {"construct_internal_locale(string)", ves_icall_System_Globalization_CultureInfo_construct_internal_locale},
+       {"construct_internal_locale_from_current_locale", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_current_locale},
+       {"construct_internal_locale_from_lcid", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_lcid},
+       {"construct_internal_locale_from_name", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name},
+       {"construct_internal_locale_from_specific_name", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_specific_name},
+       {"construct_number_format", ves_icall_System_Globalization_CultureInfo_construct_number_format},
+       {"internal_get_cultures", ves_icall_System_Globalization_CultureInfo_internal_get_cultures},
+       {"internal_is_lcid_neutral", ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral}
+};
 
-       /*
-        * System.Reflection.FieldInfo
-        */
-       "System.Reflection.FieldInfo::internal_from_handle", ves_icall_System_Reflection_FieldInfo_internal_from_handle,
+static const IcallEntry compareinfo_icalls [] = {
+       {"assign_sortkey(object,string,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_assign_sortkey},
+       {"construct_compareinfo(string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo},
+       {"free_internal_collator()", ves_icall_System_Globalization_CompareInfo_free_internal_collator},
+       {"internal_compare(string,int,int,string,int,int,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_internal_compare},
+       {"internal_index(string,int,int,char,System.Globalization.CompareOptions,bool)", ves_icall_System_Globalization_CompareInfo_internal_index_char},
+       {"internal_index(string,int,int,string,System.Globalization.CompareOptions,bool)", ves_icall_System_Globalization_CompareInfo_internal_index}
+};
 
-       /*
-        * System.Runtime.CompilerServices.RuntimeHelpers
-        */
-       "System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray,
-       "System.Runtime.CompilerServices.RuntimeHelpers::GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData,
-       "System.Runtime.CompilerServices.RuntimeHelpers::GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue,
-       "System.Runtime.CompilerServices.RuntimeHelpers::RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor,
-       
-       /*
-        * System.Threading
-        */
-       "System.Threading.Thread::Abort_internal(object)", ves_icall_System_Threading_Thread_Abort,
-       "System.Threading.Thread::ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort,
-       "System.Threading.Thread::Thread_internal", ves_icall_System_Threading_Thread_Thread_internal,
-       "System.Threading.Thread::Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal,
-       "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
-       "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
-       "System.Threading.Thread::CurrentThread_internal", mono_thread_current,
-       "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
-       "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
-       "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
-       "System.Threading.Thread::GetDomainID", ves_icall_System_Threading_Thread_GetDomainID,
-       "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
-       "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
-       "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
-       "System.Threading.Monitor::Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse,
-       "System.Threading.Monitor::Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all,
-       "System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter,
-       "System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait,
-       "System.Threading.Mutex::CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal,
-       "System.Threading.Mutex::ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal,
-       "System.Threading.NativeEventCalls::CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal,
-       "System.Threading.NativeEventCalls::SetEvent_internal",    ves_icall_System_Threading_Events_SetEvent_internal,
-       "System.Threading.NativeEventCalls::ResetEvent_internal",  ves_icall_System_Threading_Events_ResetEvent_internal,
-       "System.Threading.NativeEventCalls::CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal,
-       "System.Threading.ThreadPool::GetAvailableThreads", ves_icall_System_Threading_ThreadPool_GetAvailableThreads,
-       "System.Threading.ThreadPool::GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads,
-       "System.Threading.Thread::VolatileRead(byte&)", ves_icall_System_Threading_Thread_VolatileRead1,
-       "System.Threading.Thread::VolatileRead(double&)", ves_icall_System_Threading_Thread_VolatileRead8,
-       "System.Threading.Thread::VolatileRead(short&)", ves_icall_System_Threading_Thread_VolatileRead2,
-       "System.Threading.Thread::VolatileRead(int&)", ves_icall_System_Threading_Thread_VolatileRead4,
-       "System.Threading.Thread::VolatileRead(long&)", ves_icall_System_Threading_Thread_VolatileRead8,
-       "System.Threading.Thread::VolatileRead(IntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr,
-       "System.Threading.Thread::VolatileRead(object&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr,
-       "System.Threading.Thread::VolatileRead(sbyte&)", ves_icall_System_Threading_Thread_VolatileRead1,
-       "System.Threading.Thread::VolatileRead(float&)", ves_icall_System_Threading_Thread_VolatileRead4,
-       "System.Threading.Thread::VolatileRead(ushort&)", ves_icall_System_Threading_Thread_VolatileRead2,
-       "System.Threading.Thread::VolatileRead(uint&)", ves_icall_System_Threading_Thread_VolatileRead2,
-       "System.Threading.Thread::VolatileRead(ulong&)", ves_icall_System_Threading_Thread_VolatileRead8,
-       "System.Threading.Thread::VolatileRead(UIntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr,
-       "System.Threading.Thread::VolatileWrite(byte&,byte)", ves_icall_System_Threading_Thread_VolatileWrite1,
-       "System.Threading.Thread::VolatileWrite(double&,double)", ves_icall_System_Threading_Thread_VolatileWrite8,
-       "System.Threading.Thread::VolatileWrite(short&,short)", ves_icall_System_Threading_Thread_VolatileWrite2,
-       "System.Threading.Thread::VolatileWrite(int&,int)", ves_icall_System_Threading_Thread_VolatileWrite4,
-       "System.Threading.Thread::VolatileWrite(long&,long)", ves_icall_System_Threading_Thread_VolatileWrite8,
-       "System.Threading.Thread::VolatileWrite(IntPtr&,IntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr,
-       "System.Threading.Thread::VolatileWrite(object&,object)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr,
-       "System.Threading.Thread::VolatileWrite(sbyte&,sbyte)", ves_icall_System_Threading_Thread_VolatileWrite1,
-       "System.Threading.Thread::VolatileWrite(float&,float)", ves_icall_System_Threading_Thread_VolatileWrite4,
-       "System.Threading.Thread::VolatileWrite(ushort&,ushort)", ves_icall_System_Threading_Thread_VolatileWrite2,
-       "System.Threading.Thread::VolatileWrite(uint&,uint)", ves_icall_System_Threading_Thread_VolatileWrite2,
-       "System.Threading.Thread::VolatileWrite(ulong&,ulong)", ves_icall_System_Threading_Thread_VolatileWrite8,
-       "System.Threading.Thread::VolatileWrite(UIntPtr&,UIntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr,
+static const IcallEntry gc_icalls [] = {
+       {"GetTotalMemory", ves_icall_System_GC_GetTotalMemory},
+       {"InternalCollect", ves_icall_System_GC_InternalCollect},
+       {"KeepAlive", ves_icall_System_GC_KeepAlive},
+       {"ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize},
+       {"SuppressFinalize", ves_icall_System_GC_SuppressFinalize},
+       {"WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers}
+};
 
-       /*
-        * System.Threading.WaitHandle
-        */
-       "System.Threading.WaitHandle::WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal,
-       "System.Threading.WaitHandle::WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal,
-       "System.Threading.WaitHandle::WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal,
+static const IcallEntry famwatcher_icalls [] = {
+       {"InternalFAMNextEvent", ves_icall_System_IO_FAMW_InternalFAMNextEvent}
+};
 
-       /*
-        * System.Runtime.InteropServices.Marshal
-        */
-       "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr,
-       "System.Runtime.InteropServices.Marshal::ReadByte", ves_icall_System_Runtime_InteropServices_Marshal_ReadByte,
-       "System.Runtime.InteropServices.Marshal::ReadInt16", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt16,
-       "System.Runtime.InteropServices.Marshal::ReadInt32", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt32,
-       "System.Runtime.InteropServices.Marshal::ReadInt64", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt64,
-       "System.Runtime.InteropServices.Marshal::WriteIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_WriteIntPtr,
-       "System.Runtime.InteropServices.Marshal::WriteByte", ves_icall_System_Runtime_InteropServices_Marshal_WriteByte,
-       "System.Runtime.InteropServices.Marshal::WriteInt16", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt16,
-       "System.Runtime.InteropServices.Marshal::WriteInt32", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt32,
-       "System.Runtime.InteropServices.Marshal::WriteInt64", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt64,
-
-       "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
-       "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
-       "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
-       "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
-       "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni,
-       "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len,
-       "System.Runtime.InteropServices.Marshal::PtrToStringBSTR", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR,
-
-       "System.Runtime.InteropServices.Marshal::GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error,
-       "System.Runtime.InteropServices.Marshal::AllocHGlobal", mono_marshal_alloc,
-       "System.Runtime.InteropServices.Marshal::FreeHGlobal", mono_marshal_free,
-       "System.Runtime.InteropServices.Marshal::ReAllocHGlobal", mono_marshal_realloc,
-       "System.Runtime.InteropServices.Marshal::copy_to_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged,
-       "System.Runtime.InteropServices.Marshal::copy_from_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged,
-       "System.Runtime.InteropServices.Marshal::SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf,
-       "System.Runtime.InteropServices.Marshal::StructureToPtr", ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr,
-       "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,object)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure,
-       "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,System.Type)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type,
-       "System.Runtime.InteropServices.Marshal::OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf,
-       "System.Runtime.InteropServices.Marshal::StringToHGlobalAnsi", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
-       "System.Runtime.InteropServices.Marshal::StringToHGlobalAuto", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
-       "System.Runtime.InteropServices.Marshal::StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni,
-       "System.Runtime.InteropServices.Marshal::DestroyStructure", ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure,
-       "System.Runtime.InteropServices.Marshal::Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink,
-       "System.Runtime.InteropServices.Marshal::PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll,
-
-
-       "System.Reflection.Assembly::LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom,
-       "System.Reflection.Assembly::InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType,
-       "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
-       "System.Reflection.Assembly::FillName", ves_icall_System_Reflection_Assembly_FillName,
-       "System.Reflection.Assembly::InternalGetAssemblyName", ves_icall_System_Reflection_Assembly_InternalGetAssemblyName,
-       "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
-       "System.Reflection.Assembly::get_location", ves_icall_System_Reflection_Assembly_get_location,
-       "System.Reflection.Assembly::InternalImageRuntimeVersion", ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion,
-       "System.Reflection.Assembly::GetExecutingAssembly", ves_icall_System_Reflection_Assembly_GetExecutingAssembly,
-       "System.Reflection.Assembly::GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly,
-       "System.Reflection.Assembly::GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly,
-       "System.Reflection.Assembly::get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint,
-       "System.Reflection.Assembly::GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames,
-       "System.Reflection.Assembly::GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal,
-       "System.Reflection.Assembly::GetManifestResourceInfoInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal,
-       "System.Reflection.Assembly::GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal,
-       "System.Reflection.Assembly::GetReferencedAssemblies", ves_icall_System_Reflection_Assembly_GetReferencedAssemblies,
-       "System.Reflection.Assembly::GetNamespaces", ves_icall_System_Reflection_Assembly_GetNamespaces,
-       "System.Reflection.Assembly::GetModulesInternal", ves_icall_System_Reflection_Assembly_GetModulesInternal,
+static const IcallEntry filewatcher_icalls [] = {
+       {"InternalCloseDirectory", ves_icall_System_IO_FSW_CloseDirectory},
+       {"InternalOpenDirectory", ves_icall_System_IO_FSW_OpenDirectory},
+       {"InternalReadDirectoryChanges", ves_icall_System_IO_FSW_ReadDirectoryChanges},
+       {"InternalSupportsFSW", ves_icall_System_IO_FSW_SupportsFSW}
+};
 
-       /*
-        * System.Reflection.Module
-        */
-       "System.Reflection.Module::GetGlobalType", ves_icall_System_Reflection_Module_GetGlobalType,
-       "System.Reflection.Module::GetGuidInternal", ves_icall_System_Reflection_Module_GetGuidInternal,
-       "System.Reflection.Module::InternalGetTypes", ves_icall_System_Reflection_Module_InternalGetTypes,
+static const IcallEntry path_icalls [] = {
+       {"get_temp_path", ves_icall_System_IO_get_temp_path}
+};
 
-       /*
-        * System.MonoType.
-        */
-       "System.MonoType::getFullName", ves_icall_System_MonoType_getFullName,
-       "System.MonoType::type_from_obj", mono_type_type_from_obj,
-       "System.MonoType::GetElementType", ves_icall_MonoType_GetElementType,
-       "System.MonoType::GetArrayRank", ves_icall_MonoType_GetArrayRank,
-       "System.MonoType::get_BaseType", ves_icall_get_type_parent,
-       "System.MonoType::get_Module", ves_icall_MonoType_get_Module,
-       "System.MonoType::get_Assembly", ves_icall_MonoType_get_Assembly,
-       "System.MonoType::get_DeclaringType", ves_icall_MonoType_get_DeclaringType,
-       "System.MonoType::get_UnderlyingSystemType", ves_icall_MonoType_get_UnderlyingSystemType,
-       "System.MonoType::get_Name", ves_icall_MonoType_get_Name,
-       "System.MonoType::get_Namespace", ves_icall_MonoType_get_Namespace,
-       "System.MonoType::IsPointerImpl", ves_icall_type_ispointer,
-       "System.MonoType::IsPrimitiveImpl", ves_icall_type_isprimitive,
-       "System.MonoType::IsByRefImpl", ves_icall_type_isbyref,
-       "System.MonoType::GetField", ves_icall_Type_GetField,
-       "System.MonoType::GetFields", ves_icall_Type_GetFields,
-       "System.MonoType::GetMethods", ves_icall_Type_GetMethods,
-       "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
-       "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
-       "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
-       "System.MonoType::InternalGetEvent", ves_icall_MonoType_GetEvent,
-       "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
-       "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
-       "System.MonoType::GetNestedType", ves_icall_Type_GetNestedType,
+static const IcallEntry monoio_icalls [] = {
+       {"BeginRead", ves_icall_System_IO_MonoIO_BeginRead },
+       {"BeginWrite", ves_icall_System_IO_MonoIO_BeginWrite },
+       {"Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close},
+       {"CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile},
+       {"CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory},
+       {"CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe},
+       {"DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile},
+       {"FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose},
+       {"FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile},
+       {"FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile},
+       {"Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush},
+       {"GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory},
+       {"GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes},
+       {"GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat},
+       {"GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType},
+       {"GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength},
+       {"GetSupportsAsync", ves_icall_System_IO_MonoIO_GetSupportsAsync},
+       {"GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath},
+       {"MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile},
+       {"Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open},
+       {"Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read},
+       {"RemoveDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory},
+       {"Seek(intptr,long,System.IO.SeekOrigin,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Seek},
+       {"SetCurrentDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetCurrentDirectory},
+       {"SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes},
+       {"SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime},
+       {"SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength},
+       {"Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write},
+       {"get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar},
+       {"get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError},
+       {"get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput},
+       {"get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput},
+       {"get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar},
+       {"get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars},
+       {"get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator},
+       {"get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar}
+};
 
-       /*
-        * System.Net.Sockets I/O Services
-        */
-       "System.Net.Sockets.Socket::Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal,
-       "System.Net.Sockets.Socket::Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal,
-       "System.Net.Sockets.SocketException::WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal,
-       "System.Net.Sockets.Socket::Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal,
-       "System.Net.Sockets.Socket::Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal,
-       "System.Net.Sockets.Socket::Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal,
-       "System.Net.Sockets.Socket::Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal,
-       "System.Net.Sockets.Socket::LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal,
-       "System.Net.Sockets.Socket::RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal,
-       "System.Net.Sockets.Socket::Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal,
-       "System.Net.Sockets.Socket::Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal,
-       "System.Net.Sockets.Socket::Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal,
-       "System.Net.Sockets.Socket::RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal,
-       "System.Net.Sockets.Socket::Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal,
-       "System.Net.Sockets.Socket::SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal,
-       "System.Net.Sockets.Socket::Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal,
-       "System.Net.Sockets.Socket::Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal,
-       "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
-       "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
-       "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
-       "System.Net.Dns::GetHostByName_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByName_internal,
-       "System.Net.Dns::GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal,
-       "System.Net.Dns::GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal,
+static const IcallEntry math_icalls [] = {
+       {"Acos", ves_icall_System_Math_Acos},
+       {"Asin", ves_icall_System_Math_Asin},
+       {"Atan", ves_icall_System_Math_Atan},
+       {"Atan2", ves_icall_System_Math_Atan2},
+       {"Cos", ves_icall_System_Math_Cos},
+       {"Cosh", ves_icall_System_Math_Cosh},
+       {"Exp", ves_icall_System_Math_Exp},
+       {"Floor", ves_icall_System_Math_Floor},
+       {"Log", ves_icall_System_Math_Log},
+       {"Log10", ves_icall_System_Math_Log10},
+       {"Pow", ves_icall_System_Math_Pow},
+       {"Round", ves_icall_System_Math_Round},
+       {"Round2", ves_icall_System_Math_Round2},
+       {"Sin", ves_icall_System_Math_Sin},
+       {"Sinh", ves_icall_System_Math_Sinh},
+       {"Sqrt", ves_icall_System_Math_Sqrt},
+       {"Tan", ves_icall_System_Math_Tan},
+       {"Tanh", ves_icall_System_Math_Tanh}
+};
 
-       /*
-        * System.Char
-        */
-       "System.Char::GetNumericValue", ves_icall_System_Char_GetNumericValue,
-       "System.Char::GetUnicodeCategory", ves_icall_System_Char_GetUnicodeCategory,
-       "System.Char::IsControl", ves_icall_System_Char_IsControl,
-       "System.Char::IsDigit", ves_icall_System_Char_IsDigit,
-       "System.Char::IsLetter", ves_icall_System_Char_IsLetter,
-       "System.Char::IsLower", ves_icall_System_Char_IsLower,
-       "System.Char::IsUpper", ves_icall_System_Char_IsUpper,
-       "System.Char::IsNumber", ves_icall_System_Char_IsNumber,
-       "System.Char::IsPunctuation", ves_icall_System_Char_IsPunctuation,
-       "System.Char::IsSeparator", ves_icall_System_Char_IsSeparator,
-       "System.Char::IsSurrogate", ves_icall_System_Char_IsSurrogate,
-       "System.Char::IsSymbol", ves_icall_System_Char_IsSymbol,
-       "System.Char::IsWhiteSpace", ves_icall_System_Char_IsWhiteSpace,
-       "System.Char::ToLower", ves_icall_System_Char_ToLower,
-       "System.Char::ToUpper", ves_icall_System_Char_ToUpper,
+static const IcallEntry customattrs_icalls [] = {
+       {"GetCustomAttributes", mono_reflection_get_custom_attrs}
+};
 
-       /*
-        * System.Text.Encoding
-        */
-       "System.Text.Encoding::InternalCodePage", ves_icall_System_Text_Encoding_InternalCodePage,
+static const IcallEntry enuminfo_icalls [] = {
+       {"get_enum_info", ves_icall_get_enum_info}
+};
 
-       "System.DateTime::GetNow", ves_icall_System_DateTime_GetNow,
-       "System.CurrentTimeZone::GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData,
+static const IcallEntry fieldinfo_icalls [] = {
+       {"internal_from_handle", ves_icall_System_Reflection_FieldInfo_internal_from_handle}
+};
 
-       /*
-        * System.GC
-        */
-       "System.GC::InternalCollect", ves_icall_System_GC_InternalCollect,
-       "System.GC::GetTotalMemory", ves_icall_System_GC_GetTotalMemory,
-       "System.GC::KeepAlive", ves_icall_System_GC_KeepAlive,
-       "System.GC::ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize,
-       "System.GC::SuppressFinalize", ves_icall_System_GC_SuppressFinalize,
-       "System.GC::WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers,
-       "System.Runtime.InteropServices.GCHandle::GetTarget", ves_icall_System_GCHandle_GetTarget,
-       "System.Runtime.InteropServices.GCHandle::GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle,
-       "System.Runtime.InteropServices.GCHandle::FreeHandle", ves_icall_System_GCHandle_FreeHandle,
-       "System.Runtime.InteropServices.GCHandle::GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject,
+static const IcallEntry monotype_icalls [] = {
+       {"GetArrayRank", ves_icall_MonoType_GetArrayRank},
+       {"GetConstructors", ves_icall_Type_GetConstructors_internal},
+       {"GetConstructors_internal", ves_icall_Type_GetConstructors_internal},
+       {"GetElementType", ves_icall_MonoType_GetElementType},
+       {"GetEvents_internal", ves_icall_Type_GetEvents_internal},
+       {"GetField", ves_icall_Type_GetField},
+       {"GetFields_internal", ves_icall_Type_GetFields_internal},
+       {"GetGenericArguments", ves_icall_MonoType_GetGenericArguments},
+       {"GetInterfaces", ves_icall_Type_GetInterfaces},
+       {"GetMethodsByName", ves_icall_Type_GetMethodsByName},
+       {"GetNestedType", ves_icall_Type_GetNestedType},
+       {"GetNestedTypes", ves_icall_Type_GetNestedTypes},
+       {"GetPropertiesByName", ves_icall_Type_GetPropertiesByName},
+       {"InternalGetEvent", ves_icall_MonoType_GetEvent},
+       {"IsByRefImpl", ves_icall_type_isbyref},
+       {"IsPointerImpl", ves_icall_type_ispointer},
+       {"IsPrimitiveImpl", ves_icall_type_isprimitive},
+       {"getFullName", ves_icall_System_MonoType_getFullName},
+       {"get_Assembly", ves_icall_MonoType_get_Assembly},
+       {"get_BaseType", ves_icall_get_type_parent},
+       {"get_DeclaringMethod", ves_icall_MonoType_get_DeclaringMethod},
+       {"get_DeclaringType", ves_icall_MonoType_get_DeclaringType},
+       {"get_HasGenericArguments", ves_icall_MonoType_get_HasGenericArguments},
+       {"get_IsGenericParameter", ves_icall_MonoType_get_IsGenericParameter},
+       {"get_Module", ves_icall_MonoType_get_Module},
+       {"get_Name", ves_icall_MonoType_get_Name},
+       {"get_Namespace", ves_icall_MonoType_get_Namespace},
+       {"get_UnderlyingSystemType", ves_icall_MonoType_get_UnderlyingSystemType},
+       {"get_attributes", ves_icall_get_attributes},
+       {"type_from_obj", mono_type_type_from_obj}
+};
 
+static const IcallEntry assembly_icalls [] = {
+       {"FillName", ves_icall_System_Reflection_Assembly_FillName},
+       {"GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly},
+       {"GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly},
+       {"GetExecutingAssembly", ves_icall_System_Reflection_Assembly_GetExecutingAssembly},
+       {"GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal},
+       {"GetManifestResourceInfoInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal},
+       {"GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal},
+       {"GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames},
+       {"GetModulesInternal", ves_icall_System_Reflection_Assembly_GetModulesInternal},
+       {"GetNamespaces", ves_icall_System_Reflection_Assembly_GetNamespaces},
+       {"GetReferencedAssemblies", ves_icall_System_Reflection_Assembly_GetReferencedAssemblies},
+       {"GetTypes", ves_icall_System_Reflection_Assembly_GetTypes},
+       {"InternalGetAssemblyName", ves_icall_System_Reflection_Assembly_InternalGetAssemblyName},
+       {"InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType},
+       {"InternalImageRuntimeVersion", ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion},
+       {"LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom},
        /*
-        * System.Security.Cryptography calls
+        * Private icalls for the Mono Debugger
         */
+       {"MonoDebugger_GetLocalTypeFromSignature", ves_icall_MonoDebugger_GetLocalTypeFromSignature},
+       {"MonoDebugger_GetMethod", ves_icall_MonoDebugger_GetMethod},
+       {"MonoDebugger_GetMethodToken", ves_icall_MonoDebugger_GetMethodToken},
+       {"MonoDebugger_GetType", ves_icall_MonoDebugger_GetType},
+       /* normal icalls again */
+       {"get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint},
+       {"get_code_base", ves_icall_System_Reflection_Assembly_get_code_base},
+       {"get_location", ves_icall_System_Reflection_Assembly_get_location}
+};
 
-        "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetBytes,
-        "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetNonZeroBytes,
-       
-       /*
-        * System.Buffer
-        */
-       "System.Buffer::ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal,
-       "System.Buffer::GetByteInternal", ves_icall_System_Buffer_GetByteInternal,
-       "System.Buffer::SetByteInternal", ves_icall_System_Buffer_SetByteInternal,
-       "System.Buffer::BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal,
-       
-       /*
-        * System.IO.MonoIO
-        */
-       "System.IO.MonoIO::CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory,
-       "System.IO.MonoIO::RemoveDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory,
-       "System.IO.MonoIO::FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile,
-       "System.IO.MonoIO::FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile,
-       "System.IO.MonoIO::FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose,
-       "System.IO.MonoIO::GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
-       "System.IO.MonoIO::SetCurrentDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
-       "System.IO.MonoIO::MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile,
-       "System.IO.MonoIO::CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile,
-       "System.IO.MonoIO::DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile,
-       "System.IO.MonoIO::GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes,
-       "System.IO.MonoIO::SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes,
-       "System.IO.MonoIO::GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType,
-       "System.IO.MonoIO::GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat,
-       "System.IO.MonoIO::Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open,
-       "System.IO.MonoIO::Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close,
-       "System.IO.MonoIO::Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read,
-       "System.IO.MonoIO::Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write,
-       "System.IO.MonoIO::Seek(intptr,long,System.IO.SeekOrigin,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Seek,
-       "System.IO.MonoIO::GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength,
-       "System.IO.MonoIO::SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength,
-       "System.IO.MonoIO::SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime,
-       "System.IO.MonoIO::Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush,
-       "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
-       "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
-       "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
-       "System.IO.MonoIO::CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe,
-       "System.IO.MonoIO::get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar,
-       "System.IO.MonoIO::get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar,
-       "System.IO.MonoIO::get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar,
-       "System.IO.MonoIO::get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator,
-       "System.IO.MonoIO::get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars,
-       "System.IO.MonoIO::GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath,
+static const IcallEntry methodbase_icalls [] = {
+       {"GetCurrentMethod", ves_icall_GetCurrentMethod}
+};
 
-       /*
-        * System.Math
-        */
-       "System.Math::Floor", ves_icall_System_Math_Floor,
-       "System.Math::Round", ves_icall_System_Math_Round,
-       "System.Math::Round2", ves_icall_System_Math_Round2,
-       "System.Math::Sin", ves_icall_System_Math_Sin,
-        "System.Math::Cos", ves_icall_System_Math_Cos,
-        "System.Math::Tan", ves_icall_System_Math_Tan,
-        "System.Math::Sinh", ves_icall_System_Math_Sinh,
-        "System.Math::Cosh", ves_icall_System_Math_Cosh,
-        "System.Math::Tanh", ves_icall_System_Math_Tanh,
-        "System.Math::Acos", ves_icall_System_Math_Acos,
-        "System.Math::Asin", ves_icall_System_Math_Asin,
-        "System.Math::Atan", ves_icall_System_Math_Atan,
-        "System.Math::Atan2", ves_icall_System_Math_Atan2,
-        "System.Math::Exp", ves_icall_System_Math_Exp,
-        "System.Math::Log", ves_icall_System_Math_Log,
-        "System.Math::Log10", ves_icall_System_Math_Log10,
-        "System.Math::Pow", ves_icall_System_Math_Pow,
-        "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
+static const IcallEntry module_icalls [] = {
+       {"Close", ves_icall_System_Reflection_Module_Close},
+       {"GetGlobalType", ves_icall_System_Reflection_Module_GetGlobalType},
+       {"GetGuidInternal", ves_icall_System_Reflection_Module_GetGuidInternal},
+       {"InternalGetTypes", ves_icall_System_Reflection_Module_InternalGetTypes}
+};
 
-       /*
-        * System.Environment
-        */
-       "System.Environment::get_MachineName", ves_icall_System_Environment_get_MachineName,
-       "System.Environment::get_NewLine", ves_icall_System_Environment_get_NewLine,
-       "System.Environment::GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable,
-       "System.Environment::GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames,
-       "System.Environment::GetCommandLineArgs", mono_runtime_get_main_args,
-       "System.Environment::get_TickCount", ves_icall_System_Environment_get_TickCount,
-       "System.Environment::Exit", ves_icall_System_Environment_Exit,
-       "System.Environment::get_Platform", ves_icall_System_Environment_get_Platform,
-       "System.Environment::get_ExitCode", mono_environment_exitcode_get,
-       "System.Environment::set_ExitCode", mono_environment_exitcode_set,
-       "System.Environment::GetMachineConfigPath",     ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
+static const IcallEntry monocmethod_icalls [] = {
+       {"GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition},
+       {"InternalInvoke", ves_icall_InternalInvoke},
+       {"get_Mono_IsInflatedMethod", ves_icall_MonoMethod_get_Mono_IsInflatedMethod}
+};
 
-       /*
-        * System.Runtime.Remoting
-        */     
-       "System.Runtime.Remoting.RemotingServices::InternalExecute",
-       ves_icall_InternalExecute,
-       "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
-       ves_icall_IsTransparentProxy,
+static const IcallEntry monoeventinfo_icalls [] = {
+       {"get_event_info", ves_icall_get_event_info}
+};
 
-       /*
-        * System.Runtime.Remoting.Activation
-        */     
-       "System.Runtime.Remoting.Activation.ActivationServices::AllocateUninitializedClassInstance",
-       ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance,
-       "System.Runtime.Remoting.Activation.ActivationServices::EnableProxyActivation",
-       ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation,
+static const IcallEntry monofield_icalls [] = {
+       {"GetParentType", ves_icall_MonoField_GetParentType},
+       {"GetValueInternal", ves_icall_MonoField_GetValueInternal},
+       {"SetValueInternal", ves_icall_FieldInfo_SetValueInternal}
+};
 
-       /*
-        * System.Runtime.Remoting.Messaging
-        */     
-       "System.Runtime.Remoting.Messaging.MonoMethodMessage::InitMessage",
-       ves_icall_MonoMethodMessage_InitMessage,
+static const IcallEntry monogenericinst_icalls [] = {
+       {"GetConstructors_internal", ves_icall_MonoGenericInst_GetConstructors},
+       {"GetEvents_internal", ves_icall_MonoGenericInst_GetEvents},
+       {"GetFields_internal", ves_icall_MonoGenericInst_GetFields},
+       {"GetInterfaces_internal", ves_icall_MonoGenericInst_GetInterfaces},
+       {"GetMethods_internal", ves_icall_MonoGenericInst_GetMethods},
+       {"GetParentType", ves_icall_MonoGenericInst_GetParentType},
+       {"GetProperties_internal", ves_icall_MonoGenericInst_GetProperties},
+       {"initialize", mono_reflection_generic_inst_initialize}
+};
+
+static const IcallEntry generictypeparambuilder_icalls [] = {
+       {"initialize", mono_reflection_initialize_generic_parameter}
+};
+
+static const IcallEntry monomethod_icalls [] = {
+       {"BindGenericParameters", mono_reflection_bind_generic_method_parameters},
+       {"GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments},
+       {"GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition},
+       {"InternalInvoke", ves_icall_InternalInvoke},
+       {"get_HasGenericParameters", ves_icall_MonoMethod_get_HasGenericParameters},
+       {"get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition},
+       {"get_Mono_IsInflatedMethod", ves_icall_MonoMethod_get_Mono_IsInflatedMethod},
+       {"get_base_definition", ves_icall_MonoMethod_get_base_definition}
+};
+
+static const IcallEntry monomethodinfo_icalls [] = {
+       {"get_method_info", ves_icall_get_method_info},
+       {"get_parameter_info", ves_icall_get_parameter_info}
+};
+
+static const IcallEntry monopropertyinfo_icalls [] = {
+       {"get_property_info", ves_icall_get_property_info}
+};
+
+static const IcallEntry dns_icalls [] = {
+       {"GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal},
+       {"GetHostByName_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByName_internal},
+       {"GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal}
+};
+
+static const IcallEntry socket_icalls [] = {
+       {"Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal},
+       {"Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal},
+       {"Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal},
+       {"Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal},
+       {"Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal},
+       {"Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal},
+       {"GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal},
+       {"GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal},
+       {"Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal},
+       {"LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal},
+       {"Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal},
+       {"RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal},
+       {"RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal},
+       {"Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal},
+       {"SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal},
+       {"Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal},
+       {"SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal},
+       {"Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal},
+       {"Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal},
+       {"WSAIoctl", ves_icall_System_Net_Sockets_Socket_WSAIoctl}
+};
+
+static const IcallEntry socketex_icalls [] = {
+       {"WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal}
+};
+
+static const IcallEntry object_icalls [] = {
+       {"GetType", ves_icall_System_Object_GetType},
+       {"InternalGetHashCode", ves_icall_System_Object_GetHashCode},
+       {"MemberwiseClone", ves_icall_System_Object_MemberwiseClone},
+       {"obj_address", ves_icall_System_Object_obj_address}
+};
+
+static const IcallEntry assemblybuilder_icalls[] = {
+       {"InternalAddModule", mono_image_load_module},
+       {"basic_init", mono_image_basic_init}
+};
+
+static const IcallEntry customattrbuilder_icalls [] = {
+       {"GetBlob", mono_reflection_get_custom_attrs_blob}
+};
+
+static const IcallEntry dynamicmethod_icalls [] = {
+       {"create_dynamic_method", mono_reflection_create_dynamic_method}
+};
+
+static const IcallEntry methodbuilder_icalls [] = {
+       {"BindGenericParameters", mono_reflection_bind_generic_method_parameters}
+};
+
+static const IcallEntry modulebuilder_icalls [] = {
+       {"basic_init", mono_image_module_basic_init},
+       {"build_metadata", ves_icall_ModuleBuilder_build_metadata},
+       {"create_modified_type", ves_icall_ModuleBuilder_create_modified_type},
+       {"getDataChunk", ves_icall_ModuleBuilder_getDataChunk},
+       {"getToken", ves_icall_ModuleBuilder_getToken},
+       {"getUSIndex", mono_image_insert_string}
+};
+
+static const IcallEntry signaturehelper_icalls [] = {
+       {"get_signature_field", mono_reflection_sighelper_get_signature_field},
+       {"get_signature_local", mono_reflection_sighelper_get_signature_local}
+};
+
+static const IcallEntry typebuilder_icalls [] = {
+       {"create_internal_class", mono_reflection_create_internal_class},
+       {"create_runtime_class", mono_reflection_create_runtime_class},
+       {"get_IsGenericParameter", ves_icall_TypeBuilder_get_IsGenericParameter},
+       {"get_event_info", mono_reflection_event_builder_get_event_info},
+       {"setup_generic_class", mono_reflection_setup_generic_class},
+       {"setup_internal_class", mono_reflection_setup_internal_class}
+};
+
+static const IcallEntry runtimehelpers_icalls [] = {
+       {"GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue},
+       {"GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData},
+       {"InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray},
+       {"RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor}
+};
+
+static const IcallEntry gchandle_icalls [] = {
+       {"FreeHandle", ves_icall_System_GCHandle_FreeHandle},
+       {"GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject},
+       {"GetTarget", ves_icall_System_GCHandle_GetTarget},
+       {"GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle}
+};
+
+static const IcallEntry marshal_icalls [] = {
+       {"AllocCoTaskMem", ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMem},
+       {"AllocHGlobal", mono_marshal_alloc},
+       {"DestroyStructure", ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure},
+       {"FreeCoTaskMem", ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem},
+       {"FreeHGlobal", mono_marshal_free},
+       {"GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error},
+       {"OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf},
+       {"Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink},
+       {"PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll},
+       {"PtrToStringAnsi(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi},
+       {"PtrToStringAnsi(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len},
+       {"PtrToStringAuto(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi},
+       {"PtrToStringAuto(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len},
+       {"PtrToStringBSTR", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR},
+       {"PtrToStringUni(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni},
+       {"PtrToStringUni(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len},
+       {"PtrToStructure(intptr,System.Type)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type},
+       {"PtrToStructure(intptr,object)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure},
+       {"ReAllocHGlobal", mono_marshal_realloc},
+       {"ReadByte", ves_icall_System_Runtime_InteropServices_Marshal_ReadByte},
+       {"ReadInt16", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt16},
+       {"ReadInt32", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt32},
+       {"ReadInt64", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt64},
+       {"ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr},
+       {"SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf},
+       {"StringToHGlobalAnsi", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi},
+       {"StringToHGlobalAuto", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi},
+       {"StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni},
+       {"StructureToPtr", ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr},
+       {"WriteByte", ves_icall_System_Runtime_InteropServices_Marshal_WriteByte},
+       {"WriteInt16", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt16},
+       {"WriteInt32", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt32},
+       {"WriteInt64", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt64},
+       {"WriteIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_WriteIntPtr},
+       {"copy_from_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged},
+       {"copy_to_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged}
+};
+
+static const IcallEntry activationservices_icalls [] = {
+       {"AllocateUninitializedClassInstance", ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance},
+       {"EnableProxyActivation", ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation}
+};
+
+static const IcallEntry monomethodmessage_icalls [] = {
+       {"InitMessage", ves_icall_MonoMethodMessage_InitMessage}
+};
        
-       /*
-        * System.Runtime.Remoting.Proxies
-        */     
-       "System.Runtime.Remoting.Proxies.RealProxy::InternalGetTransparentProxy", 
-       ves_icall_Remoting_RealProxy_GetTransparentProxy,
+static const IcallEntry realproxy_icalls [] = {
+       {"InternalGetProxyType", ves_icall_Remoting_RealProxy_InternalGetProxyType},
+       {"InternalGetTransparentProxy", ves_icall_Remoting_RealProxy_GetTransparentProxy}
+};
 
-       /*
-        * System.Threading.Interlocked
-        */
-       "System.Threading.Interlocked::Increment(int&)", ves_icall_System_Threading_Interlocked_Increment_Int,
-       "System.Threading.Interlocked::Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long,
-       "System.Threading.Interlocked::Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int,
-       "System.Threading.Interlocked::Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long,
-       "System.Threading.Interlocked::CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int,
-       "System.Threading.Interlocked::CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object,
-       "System.Threading.Interlocked::CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single,
-       "System.Threading.Interlocked::Exchange(int&,int)", ves_icall_System_Threading_Interlocked_Exchange_Int,
-       "System.Threading.Interlocked::Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object,
-       "System.Threading.Interlocked::Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single,
-       "System.Threading.Thread::current_lcid()", ves_icall_System_Threading_Thread_current_lcid,
+static const IcallEntry remotingservices_icalls [] = {
+       {"InternalExecute", ves_icall_InternalExecute},
+       {"IsTransparentProxy", ves_icall_IsTransparentProxy}
+};
 
-       /*
-        * System.Diagnostics.Process
-        */
-       "System.Diagnostics.Process::GetProcess_internal(int)", ves_icall_System_Diagnostics_Process_GetProcess_internal,
-       "System.Diagnostics.Process::GetProcesses_internal()", ves_icall_System_Diagnostics_Process_GetProcesses_internal,
-       "System.Diagnostics.Process::GetPid_internal()", ves_icall_System_Diagnostics_Process_GetPid_internal,
-       "System.Diagnostics.Process::Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal,
-       "System.Diagnostics.Process::GetModules_internal()", ves_icall_System_Diagnostics_Process_GetModules_internal,
-       "System.Diagnostics.Process::Start_internal(string,string,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal,
-       "System.Diagnostics.Process::WaitForExit_internal(intptr,int)", ves_icall_System_Diagnostics_Process_WaitForExit_internal,
-       "System.Diagnostics.Process::ExitTime_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitTime_internal,
-       "System.Diagnostics.Process::StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal,
-       "System.Diagnostics.Process::ExitCode_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitCode_internal,
-       "System.Diagnostics.Process::ProcessName_internal(intptr)", ves_icall_System_Diagnostics_Process_ProcessName_internal,
-       "System.Diagnostics.Process::GetWorkingSet_internal(intptr,int&,int&)", ves_icall_System_Diagnostics_Process_GetWorkingSet_internal,
-       "System.Diagnostics.Process::SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal,
-       "System.Diagnostics.FileVersionInfo::GetVersionInfo_internal(string)", ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal,
+static const IcallEntry rng_icalls [] = {
+       {"InternalGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetBytes}
+};
 
-       /* 
-        * System.Delegate
-        */
-       "System.Delegate::CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal,
+static const IcallEntry methodhandle_icalls [] = {
+       {"GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer}
+};
 
-       /*
-        * System.IO.Path
-        */
-       "System.IO.Path::get_temp_path", ves_icall_System_IO_get_temp_path,
+static const IcallEntry string_icalls [] = {
+       {".ctor(char*)", ves_icall_System_String_ctor_charp},
+       {".ctor(char*,int,int)", ves_icall_System_String_ctor_charp_int_int},
+       {".ctor(char,int)", ves_icall_System_String_ctor_char_int},
+       {".ctor(char[])", ves_icall_System_String_ctor_chara},
+       {".ctor(char[],int,int)", ves_icall_System_String_ctor_chara_int_int},
+       {".ctor(sbyte*)", ves_icall_System_String_ctor_sbytep},
+       {".ctor(sbyte*,int,int)", ves_icall_System_String_ctor_sbytep_int_int},
+       {".ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding},
+       {"GetHashCode", ves_icall_System_String_GetHashCode},
+       {"InternalAllocateStr", ves_icall_System_String_InternalAllocateStr},
+       {"InternalCopyTo", ves_icall_System_String_InternalCopyTo},
+       {"InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny},
+       {"InternalInsert", ves_icall_System_String_InternalInsert},
+       {"InternalIntern", ves_icall_System_String_InternalIntern},
+       {"InternalIsInterned", ves_icall_System_String_InternalIsInterned},
+       {"InternalJoin", ves_icall_System_String_InternalJoin},
+       {"InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny},
+       {"InternalPad", ves_icall_System_String_InternalPad},
+       {"InternalRemove", ves_icall_System_String_InternalRemove},
+       {"InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char},
+       {"InternalReplace(string,string,System.Globalization.CompareInfo)", ves_icall_System_String_InternalReplace_Str_Comp},
+       {"InternalSplit", ves_icall_System_String_InternalSplit},
+       {"InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str},
+       {"InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN},
+       {"InternalToLower(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToLower_Comp},
+       {"InternalToUpper(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToUpper_Comp},
+       {"InternalTrim", ves_icall_System_String_InternalTrim},
+       {"get_Chars", ves_icall_System_String_get_Chars}
+};
 
-       /*
-        * Private icalls for the Mono Debugger
-        */
-       "System.Reflection.Assembly::MonoDebugger_GetMethod",
-       ves_icall_MonoDebugger_GetMethod,
+static const IcallEntry encoding_icalls [] = {
+       {"InternalCodePage", ves_icall_System_Text_Encoding_InternalCodePage}
+};
 
-       "System.Reflection.Assembly::MonoDebugger_GetMethodToken",
-       ves_icall_MonoDebugger_GetMethodToken,
+static const IcallEntry monitor_icalls [] = {
+       {"Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit},
+       {"Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse},
+       {"Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all},
+       {"Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner},
+       {"Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised},
+       {"Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter},
+       {"Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait}
+};
 
-       "System.Reflection.Assembly::MonoDebugger_GetLocalTypeFromSignature",
-       ves_icall_MonoDebugger_GetLocalTypeFromSignature,
+static const IcallEntry interlocked_icalls [] = {
+       {"CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int},
+       {"CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object},
+       {"CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single},
+       {"Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int},
+       {"Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long},
+       {"Exchange(int&,int)", ves_icall_System_Threading_Interlocked_Exchange_Int},
+       {"Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object},
+       {"Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single},
+       {"Increment(int&)", ves_icall_System_Threading_Interlocked_Increment_Int},
+       {"Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long}
+};
 
-       "System.Reflection.Assembly::MonoDebugger_GetType",
-       ves_icall_MonoDebugger_GetType,
+static const IcallEntry mutex_icalls [] = {
+       {"CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal},
+       {"ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal}
+};
 
-       /*
-        * System.Configuration
-        */
-       "System.Configuration.DefaultConfig::get_machine_config_path",
-       ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
+static const IcallEntry nativeevents_icalls [] = {
+       {"CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal},
+       {"CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal},
+       {"ResetEvent_internal",  ves_icall_System_Threading_Events_ResetEvent_internal},
+       {"SetEvent_internal",    ves_icall_System_Threading_Events_SetEvent_internal}
+};
 
-       /*
-        * System.Diagnostics.DefaultTraceListener
-        */
-       "System.Diagnostics.DefaultTraceListener::WriteWindowsDebugString",
-       ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString,
-       /*
-        * System.Activator
-        */
-       "System.Activator::CreateInstanceInternal",
-       ves_icall_System_Activator_CreateInstanceInternal,
+static const IcallEntry thread_icalls [] = {
+       {"Abort_internal(object)", ves_icall_System_Threading_Thread_Abort},
+       {"CurrentThread_internal", mono_thread_current},
+       {"GetDomainID", ves_icall_System_Threading_Thread_GetDomainID},
+       {"GetName_internal", ves_icall_System_Threading_Thread_GetName_internal},
+       {"Join_internal", ves_icall_System_Threading_Thread_Join_internal},
+       {"ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort},
+       {"SetName_internal", ves_icall_System_Threading_Thread_SetName_internal},
+       {"Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal},
+       {"SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup},
+       {"SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store},
+       {"Start_internal", ves_icall_System_Threading_Thread_Start_internal},
+       {"Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal},
+       {"Thread_internal", ves_icall_System_Threading_Thread_Thread_internal},
+       {"VolatileRead(IntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
+       {"VolatileRead(UIntPtr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
+       {"VolatileRead(byte&)", ves_icall_System_Threading_Thread_VolatileRead1},
+       {"VolatileRead(double&)", ves_icall_System_Threading_Thread_VolatileRead8},
+       {"VolatileRead(float&)", ves_icall_System_Threading_Thread_VolatileRead4},
+       {"VolatileRead(int&)", ves_icall_System_Threading_Thread_VolatileRead4},
+       {"VolatileRead(long&)", ves_icall_System_Threading_Thread_VolatileRead8},
+       {"VolatileRead(object&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr},
+       {"VolatileRead(sbyte&)", ves_icall_System_Threading_Thread_VolatileRead1},
+       {"VolatileRead(short&)", ves_icall_System_Threading_Thread_VolatileRead2},
+       {"VolatileRead(uint&)", ves_icall_System_Threading_Thread_VolatileRead2},
+       {"VolatileRead(ulong&)", ves_icall_System_Threading_Thread_VolatileRead8},
+       {"VolatileRead(ushort&)", ves_icall_System_Threading_Thread_VolatileRead2},
+       {"VolatileWrite(IntPtr&,IntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
+       {"VolatileWrite(UIntPtr&,UIntPtr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
+       {"VolatileWrite(byte&,byte)", ves_icall_System_Threading_Thread_VolatileWrite1},
+       {"VolatileWrite(double&,double)", ves_icall_System_Threading_Thread_VolatileWrite8},
+       {"VolatileWrite(float&,float)", ves_icall_System_Threading_Thread_VolatileWrite4},
+       {"VolatileWrite(int&,int)", ves_icall_System_Threading_Thread_VolatileWrite4},
+       {"VolatileWrite(long&,long)", ves_icall_System_Threading_Thread_VolatileWrite8},
+       {"VolatileWrite(object&,object)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr},
+       {"VolatileWrite(sbyte&,sbyte)", ves_icall_System_Threading_Thread_VolatileWrite1},
+       {"VolatileWrite(short&,short)", ves_icall_System_Threading_Thread_VolatileWrite2},
+       {"VolatileWrite(uint&,uint)", ves_icall_System_Threading_Thread_VolatileWrite2},
+       {"VolatileWrite(ulong&,ulong)", ves_icall_System_Threading_Thread_VolatileWrite8},
+       {"VolatileWrite(ushort&,ushort)", ves_icall_System_Threading_Thread_VolatileWrite2},
+       {"current_lcid()", ves_icall_System_Threading_Thread_current_lcid}
+};
 
-       /* 
-        * System.Web
-        */
-       "System.Web.Util.ICalls::GetMachineConfigPath",
-       ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
+static const IcallEntry threadpool_icalls [] = {
+       {"BindHandleInternal", ves_icall_System_Threading_ThreadPool_BindHandle},
+       {"GetAvailableThreads", ves_icall_System_Threading_ThreadPool_GetAvailableThreads},
+       {"GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads}
+};
 
-       "System.Web.Util.ICalls::GetMachineInstallDirectory",
-       ves_icall_System_Web_Util_ICalls_get_machine_install_dir,
+static const IcallEntry waithandle_icalls [] = {
+       {"WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal},
+       {"WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal},
+       {"WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal}
+};
 
-       /*
-        * System.Globalization
-        */
-       "System.Globalization.CultureInfo::construct_internal_locale(string)", ves_icall_System_Globalization_CultureInfo_construct_internal_locale,
-       "System.Globalization.CompareInfo::construct_compareinfo(string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo,
-       "System.Globalization.CompareInfo::internal_compare(string,string,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_internal_compare,
-       "System.Globalization.CompareInfo::free_internal_collator()", ves_icall_System_Globalization_CompareInfo_free_internal_collator,
-       "System.Globalization.CompareInfo::assign_sortkey(object,string,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_assign_sortkey,
-       "System.Globalization.CompareInfo::internal_index(string,int,int,string,System.Globalization.CompareOptions,bool)", ves_icall_System_Globalization_CompareInfo_internal_index,
-       "System.String::InternalReplace(string,string,System.Globalization.CompareInfo)", ves_icall_System_String_InternalReplace_Str_Comp,
-       "System.String::InternalToLower(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToLower_Comp,
-       "System.String::InternalToUpper(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToUpper_Comp,
+static const IcallEntry type_icalls [] = {
+       {"BindGenericParameters", ves_icall_Type_BindGenericParameters},
+       {"Equals", ves_icall_type_Equals},
+       {"GetGenericParameterPosition", ves_icall_Type_GetGenericParameterPosition},
+       {"GetGenericTypeDefinition_impl", ves_icall_Type_GetGenericTypeDefinition_impl},
+       {"GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData},
+       {"GetTypeCode", ves_icall_type_GetTypeCode},
+       {"IsArrayImpl", ves_icall_Type_IsArrayImpl},
+       {"IsInstanceOfType", ves_icall_type_IsInstanceOfType},
+       {"get_IsGenericInstance", ves_icall_Type_get_IsGenericInstance},
+       {"get_IsGenericTypeDefinition", ves_icall_Type_get_IsGenericTypeDefinition},
+       {"internal_from_handle", ves_icall_type_from_handle},
+       {"internal_from_name", ves_icall_type_from_name},
+       {"make_array_type", ves_icall_Type_make_array_type},
+       {"make_byref_type", ves_icall_Type_make_byref_type},
+       {"type_is_assignable_from", ves_icall_type_is_assignable_from},
+       {"type_is_subtype_of", ves_icall_type_is_subtype_of}
+};
 
-       /*
-        * add other internal calls here
-        */
+static const IcallEntry typedref_icalls [] = {
+       {"ToObject",    mono_TypedReference_ToObject}
+};
+
+static const IcallEntry valuetype_icalls [] = {
+       {"InternalEquals", ves_icall_System_ValueType_Equals},
+       {"InternalGetHashCode", ves_icall_System_ValueType_InternalGetHashCode}
+};
 
-       /* These will be deleted after the next release */
-       "System.String::InternalEquals", ves_icall_System_String_InternalEquals,
-       "System.String::InternalIndexOf(char,int,int)", ves_icall_System_String_InternalIndexOf_Char,
-       "System.String::InternalIndexOf(string,int,int)", ves_icall_System_String_InternalIndexOf_Str,
-       "System.String::InternalLastIndexOf(char,int,int)", ves_icall_System_String_InternalLastIndexOf_Char,
-       "System.String::InternalLastIndexOf(string,int,int)", ves_icall_System_String_InternalLastIndexOf_Str,
-       "System.String::InternalCompare(string,int,string,int,int,int)", ves_icall_System_String_InternalCompareStr_N,
-       "System.String::InternalReplace(string,string)", ves_icall_System_String_InternalReplace_Str,
-       "System.String::InternalToLower()", ves_icall_System_String_InternalToLower,
-       "System.String::InternalToUpper()", ves_icall_System_String_InternalToUpper,
-       "System.Globalization.CultureInfo::construct_compareinfo(object,string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo,
-
-       NULL, NULL
+static const IcallEntry web_icalls [] = {
+       {"GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path},
+       {"GetMachineInstallDirectory", ves_icall_System_Web_Util_ICalls_get_machine_install_dir}
 };
 
+/* proto
+static const IcallEntry array_icalls [] = {
+};
+
+*/
+
+/* keep the entries all sorted */
+static const IcallMap icall_entries [] = {
+       {"System.Activator", activator_icalls, G_N_ELEMENTS (activator_icalls)},
+       {"System.AppDomain", appdomain_icalls, G_N_ELEMENTS (appdomain_icalls)},
+       {"System.AppDomainSetup", appdomainsetup_icalls, G_N_ELEMENTS (appdomainsetup_icalls)},
+       {"System.ArgIterator", argiterator_icalls, G_N_ELEMENTS (argiterator_icalls)},
+       {"System.Array", array_icalls, G_N_ELEMENTS (array_icalls)},
+       {"System.Buffer", buffer_icalls, G_N_ELEMENTS (buffer_icalls)},
+       {"System.Char", char_icalls, G_N_ELEMENTS (char_icalls)},
+       {"System.Configuration.DefaultConfig", defaultconf_icalls, G_N_ELEMENTS (defaultconf_icalls)},
+       {"System.CurrentTimeZone", timezone_icalls, G_N_ELEMENTS (timezone_icalls)},
+       {"System.DateTime", datetime_icalls, G_N_ELEMENTS (datetime_icalls)},
+       {"System.Decimal", decimal_icalls, G_N_ELEMENTS (decimal_icalls)},
+       {"System.Delegate", delegate_icalls, G_N_ELEMENTS (delegate_icalls)},
+       {"System.Diagnostics.DefaultTraceListener", tracelist_icalls, G_N_ELEMENTS (tracelist_icalls)},
+       {"System.Diagnostics.FileVersionInfo", fileversion_icalls, G_N_ELEMENTS (fileversion_icalls)},
+       {"System.Diagnostics.Process", process_icalls, G_N_ELEMENTS (process_icalls)},
+       {"System.Double", double_icalls, G_N_ELEMENTS (double_icalls)},
+       {"System.Enum", enum_icalls, G_N_ELEMENTS (enum_icalls)},
+       {"System.Environment", environment_icalls, G_N_ELEMENTS (environment_icalls)},
+       {"System.GC", gc_icalls, G_N_ELEMENTS (gc_icalls)},
+       {"System.Globalization.CompareInfo", compareinfo_icalls, G_N_ELEMENTS (compareinfo_icalls)},
+       {"System.Globalization.CultureInfo", cultureinfo_icalls, G_N_ELEMENTS (cultureinfo_icalls)},
+       {"System.IO.FAMWatcher", famwatcher_icalls, G_N_ELEMENTS (famwatcher_icalls)},
+       {"System.IO.FileSystemWatcher", filewatcher_icalls, G_N_ELEMENTS (filewatcher_icalls)},
+       {"System.IO.MonoIO", monoio_icalls, G_N_ELEMENTS (monoio_icalls)},
+       {"System.IO.Path", path_icalls, G_N_ELEMENTS (path_icalls)},
+       {"System.Math", math_icalls, G_N_ELEMENTS (math_icalls)},
+       {"System.MonoCustomAttrs", customattrs_icalls, G_N_ELEMENTS (customattrs_icalls)},
+       {"System.MonoEnumInfo", enuminfo_icalls, G_N_ELEMENTS (enuminfo_icalls)},
+       {"System.MonoType", monotype_icalls, G_N_ELEMENTS (monotype_icalls)},
+       {"System.Net.Dns", dns_icalls, G_N_ELEMENTS (dns_icalls)},
+       {"System.Net.Sockets.Socket", socket_icalls, G_N_ELEMENTS (socket_icalls)},
+       {"System.Net.Sockets.SocketException", socketex_icalls, G_N_ELEMENTS (socketex_icalls)},
+       {"System.Object", object_icalls, G_N_ELEMENTS (object_icalls)},
+       {"System.Reflection.Assembly", assembly_icalls, G_N_ELEMENTS (assembly_icalls)},
+       {"System.Reflection.Emit.AssemblyBuilder", assemblybuilder_icalls, G_N_ELEMENTS (assemblybuilder_icalls)},
+       {"System.Reflection.Emit.CustomAttributeBuilder", customattrbuilder_icalls, G_N_ELEMENTS (customattrbuilder_icalls)},
+       {"System.Reflection.Emit.DynamicMethod", dynamicmethod_icalls, G_N_ELEMENTS (dynamicmethod_icalls)},
+       {"System.Reflection.Emit.GenericTypeParameterBuilder", generictypeparambuilder_icalls, G_N_ELEMENTS (generictypeparambuilder_icalls)},
+       {"System.Reflection.Emit.MethodBuilder", methodbuilder_icalls, G_N_ELEMENTS (methodbuilder_icalls)},
+       {"System.Reflection.Emit.ModuleBuilder", modulebuilder_icalls, G_N_ELEMENTS (modulebuilder_icalls)},
+       {"System.Reflection.Emit.SignatureHelper", signaturehelper_icalls, G_N_ELEMENTS (signaturehelper_icalls)},
+       {"System.Reflection.Emit.TypeBuilder", typebuilder_icalls, G_N_ELEMENTS (typebuilder_icalls)},
+       {"System.Reflection.FieldInfo", fieldinfo_icalls, G_N_ELEMENTS (fieldinfo_icalls)},
+       {"System.Reflection.MethodBase", methodbase_icalls, G_N_ELEMENTS (methodbase_icalls)},
+       {"System.Reflection.Module", module_icalls, G_N_ELEMENTS (module_icalls)},
+       {"System.Reflection.MonoCMethod", monocmethod_icalls, G_N_ELEMENTS (monocmethod_icalls)},
+       {"System.Reflection.MonoEventInfo", monoeventinfo_icalls, G_N_ELEMENTS (monoeventinfo_icalls)},
+       {"System.Reflection.MonoField", monofield_icalls, G_N_ELEMENTS (monofield_icalls)},
+       {"System.Reflection.MonoGenericInst", monogenericinst_icalls, G_N_ELEMENTS (monogenericinst_icalls)},
+       {"System.Reflection.MonoMethod", monomethod_icalls, G_N_ELEMENTS (monomethod_icalls)},
+       {"System.Reflection.MonoMethodInfo", monomethodinfo_icalls, G_N_ELEMENTS (monomethodinfo_icalls)},
+       {"System.Reflection.MonoPropertyInfo", monopropertyinfo_icalls, G_N_ELEMENTS (monopropertyinfo_icalls)},
+       {"System.Runtime.CompilerServices.RuntimeHelpers", runtimehelpers_icalls, G_N_ELEMENTS (runtimehelpers_icalls)},
+       {"System.Runtime.InteropServices.GCHandle", gchandle_icalls, G_N_ELEMENTS (gchandle_icalls)},
+       {"System.Runtime.InteropServices.Marshal", marshal_icalls, G_N_ELEMENTS (marshal_icalls)},
+       {"System.Runtime.Remoting.Activation.ActivationServices", activationservices_icalls, G_N_ELEMENTS (activationservices_icalls)},
+       {"System.Runtime.Remoting.Messaging.MonoMethodMessage", monomethodmessage_icalls, G_N_ELEMENTS (monomethodmessage_icalls)},
+       {"System.Runtime.Remoting.Proxies.RealProxy", realproxy_icalls, G_N_ELEMENTS (realproxy_icalls)},
+       {"System.Runtime.Remoting.RemotingServices", remotingservices_icalls, G_N_ELEMENTS (remotingservices_icalls)},
+       {"System.RuntimeMethodHandle", methodhandle_icalls, G_N_ELEMENTS (methodhandle_icalls)},
+       {"System.Security.Cryptography.RNGCryptoServiceProvider", rng_icalls, G_N_ELEMENTS (rng_icalls)},
+       {"System.String", string_icalls, G_N_ELEMENTS (string_icalls)},
+       {"System.Text.Encoding", encoding_icalls, G_N_ELEMENTS (encoding_icalls)},
+       {"System.Threading.Interlocked", interlocked_icalls, G_N_ELEMENTS (interlocked_icalls)},
+       {"System.Threading.Monitor", monitor_icalls, G_N_ELEMENTS (monitor_icalls)},
+       {"System.Threading.Mutex", mutex_icalls, G_N_ELEMENTS (mutex_icalls)},
+       {"System.Threading.NativeEventCalls", nativeevents_icalls, G_N_ELEMENTS (nativeevents_icalls)},
+       {"System.Threading.Thread", thread_icalls, G_N_ELEMENTS (thread_icalls)},
+       {"System.Threading.ThreadPool", threadpool_icalls, G_N_ELEMENTS (threadpool_icalls)},
+       {"System.Threading.WaitHandle", waithandle_icalls, G_N_ELEMENTS (waithandle_icalls)},
+       {"System.Type", type_icalls, G_N_ELEMENTS (type_icalls)},
+       {"System.TypedReference", typedref_icalls, G_N_ELEMENTS (typedref_icalls)},
+       {"System.ValueType", valuetype_icalls, G_N_ELEMENTS (valuetype_icalls)},
+       {"System.Web.Util.ICalls", web_icalls, G_N_ELEMENTS (web_icalls)}
+};
+
+static GHashTable *icall_hash = NULL;
+
 void
 mono_init_icall (void)
 {
-       const char *name;
        int i = 0;
 
-       while ((name = icall_map [i])) {
-               mono_add_internal_call (name, icall_map [i+1]);
-               i += 2;
+       /* check that tables are sorted: disable in release */
+       if (TRUE) {
+               int j;
+               const IcallMap *imap;
+               const IcallEntry *ientry;
+               const char *prev_class = NULL;
+               const char *prev_method;
+               
+               for (i = 0; i < G_N_ELEMENTS (icall_entries); ++i) {
+                       imap = &icall_entries [i];
+                       prev_method = NULL;
+                       if (prev_class && strcmp (prev_class, imap->klass) >= 0)
+                               g_print ("class %s should come before class %s\n", imap->klass, prev_class);
+                       prev_class = imap->klass;
+                       for (j = 0; j < imap->size; ++j) {
+                               ientry = &imap->icalls [j];
+                               if (prev_method && strcmp (prev_method, ientry->method) >= 0)
+                                       g_print ("method %s should come before method %s\n", ientry->method, prev_method);
+                               prev_method = ientry->method;
+                       }
+               }
        }
-       
+
+       icall_hash = g_hash_table_new (g_str_hash , g_str_equal);
+}
+
+void
+mono_add_internal_call (const char *name, gconstpointer method)
+{
+       mono_loader_lock ();
+
+       g_hash_table_insert (icall_hash, g_strdup (name), (gpointer) method);
+
+       mono_loader_unlock ();
 }
 
+static int
+compare_class_imap (const void *key, const void *elem)
+{
+       const IcallMap* imap = (const IcallMap*)elem;
+       return strcmp (key, imap->klass);
+}
+
+static const IcallMap*
+find_class_icalls (const char *name)
+{
+       return (const IcallMap*) bsearch (name, icall_entries, G_N_ELEMENTS (icall_entries), sizeof (IcallMap), compare_class_imap);
+}
+
+static int
+compare_method_imap (const void *key, const void *elem)
+{
+       const IcallEntry* ientry = (const IcallEntry*)elem;
+       return strcmp (key, ientry->method);
+}
+
+static void*
+find_method_icall (const IcallMap *imap, const char *name)
+{
+       const IcallEntry *ientry = (const IcallEntry*) bsearch (name, imap->icalls, imap->size, sizeof (IcallEntry), compare_method_imap);
+       if (ientry)
+               return (void*)ientry->func;
+       return NULL;
+}
+
+/* 
+ * we should probably export this as an helper (handle nested types).
+ * Returns the number of chars written in buf.
+ */
+static int
+concat_class_name (char *buf, int bufsize, MonoClass *klass)
+{
+       int nspacelen, cnamelen;
+       nspacelen = strlen (klass->name_space);
+       cnamelen = strlen (klass->name);
+       if (nspacelen + cnamelen + 2 > bufsize)
+               return 0;
+       if (nspacelen) {
+               memcpy (buf, klass->name_space, nspacelen);
+               buf [nspacelen ++] = '.';
+       }
+       memcpy (buf + nspacelen, klass->name, cnamelen);
+       buf [nspacelen + cnamelen] = 0;
+       return nspacelen + cnamelen;
+}
+
+gpointer
+mono_lookup_internal_call (MonoMethod *method)
+{
+       char *sigstart;
+       char *tmpsig;
+       char mname [2048];
+       int typelen = 0, mlen, siglen;
+       gpointer res;
+       const IcallMap *imap;
+
+       g_assert (method != NULL);
+
+       typelen = concat_class_name (mname, sizeof (mname), method->klass);
+       if (!typelen)
+               return NULL;
+
+       imap = find_class_icalls (mname);
+
+       mname [typelen] = ':';
+       mname [typelen + 1] = ':';
+
+       mlen = strlen (method->name);
+       memcpy (mname + typelen + 2, method->name, mlen);
+       sigstart = mname + typelen + 2 + mlen;
+       *sigstart = 0;
+
+       tmpsig = mono_signature_get_desc (method->signature, TRUE);
+       siglen = strlen (tmpsig);
+       if (typelen + mlen + siglen + 6 > sizeof (mname))
+               return NULL;
+       sigstart [0] = '(';
+       memcpy (sigstart + 1, tmpsig, siglen);
+       sigstart [siglen + 1] = ')';
+       sigstart [siglen + 2] = 0;
+       g_free (tmpsig);
+       
+       mono_loader_lock ();
+
+       res = g_hash_table_lookup (icall_hash, mname);
+       if (res) {
+               mono_loader_unlock ();
+               return res;
+       }
+       /* try without signature */
+       *sigstart = 0;
+       res = g_hash_table_lookup (icall_hash, mname);
+       if (res) {
+               mono_loader_unlock ();
+               return res;
+       }
+
+       /* it wasn't found in the static call tables */
+       if (!imap) {
+               mono_loader_unlock ();
+               return NULL;
+       }
+       res = find_method_icall (imap, sigstart - mlen);
+       if (res) {
+               mono_loader_unlock ();
+               return res;
+       }
+       /* try _with_ signature */
+       *sigstart = '(';
+       res = find_method_icall (imap, sigstart - mlen);
+       if (res) {
+               mono_loader_unlock ();
+               return res;
+       }
+       
+       g_warning ("cant resolve internal call to \"%s\" (tested without signature also)", mname);
+       g_print ("\nYour mono runtime and corlib are out of sync.\n");
+       g_print ("Corlib is: %s\n", method->klass->image->name);
+       g_print ("\nWhen you update one from cvs you need to update, compile and install\nthe other too.\n");
+       g_print ("Do not report this as a bug unless you're sure you have updated correctly:\nyou probably have a broken mono install.\n");
+       g_print ("If you see other errors or faults after this message they are probably related\n");
+       g_print ("and you need to fix your mono install first.\n");
+
+       mono_loader_unlock ();
+
+       return NULL;
+}