Permalink
Browse files

Fix the lookup of some ctors in exception.c. Fixes #10774.

  • Loading branch information...
1 parent 1d8669c commit f25263db7a2394a4409902d4efe0ace3f7a7d434 @vargaz vargaz committed Mar 1, 2013
Showing with 18 additions and 5 deletions.
  1. +18 −5 mono/metadata/exception.c
View
@@ -574,14 +574,16 @@ mono_get_exception_type_initialization (const gchar *type_name, MonoException *i
mono_class_init (klass);
- /* TypeInitializationException only has 1 ctor with 2 args */
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
- if (!strcmp (".ctor", mono_method_get_name (method)) && mono_method_signature (method)->param_count == 2)
- break;
+ if (!strcmp (".ctor", mono_method_get_name (method))) {
+ MonoMethodSignature *sig = mono_method_signature (method);
+
+ if (sig->param_count == 2 && sig->params [0]->type == MONO_TYPE_STRING && mono_class_from_mono_type (sig->params [1]) == mono_defaults.exception_class)
+ break;
+ }
method = NULL;
}
-
g_assert (method);
args [0] = mono_string_new (mono_domain_get (), type_name);
@@ -738,12 +740,23 @@ mono_get_exception_reflection_type_load (MonoArray *types, MonoArray *exceptions
gpointer args [2];
MonoObject *exc;
MonoMethod *method;
+ gpointer iter;
klass = mono_class_from_name (mono_get_corlib (), "System.Reflection", "ReflectionTypeLoadException");
g_assert (klass);
mono_class_init (klass);
- method = mono_class_get_method_from_name (klass, ".ctor", 2);
+ /* Find the Type[], Exception[] ctor */
+ iter = NULL;
+ while ((method = mono_class_get_methods (klass, &iter))) {
+ if (!strcmp (".ctor", mono_method_get_name (method))) {
+ MonoMethodSignature *sig = mono_method_signature (method);
+
+ if (sig->param_count == 2 && sig->params [0]->type == MONO_TYPE_SZARRAY && sig->params [1]->type == MONO_TYPE_SZARRAY)
+ break;
+ }
+ method = NULL;
+ }
g_assert (method);
args [0] = types;

0 comments on commit f25263d

Please sign in to comment.