Hello,
> On a somewhat related note, is it possible to get the dlopen()/dlsym()
> error messages that are printed out when you run with
> MONO_LOG_MASK=dll put into the message field of the
> DllNotFoundException? That would make debugging these issues a lot
> easier.
So my early attempt at doing this fails because it seems to call the
function twice: in one case it gets the info, int he second case it
ignores the information.
Am going to have to ask Paolo/Zoltan for their feedback.
Miguel.
Index: metadata/loader.c
===================================================================
--- metadata/loader.c (revision 76089)
+++ metadata/loader.c (working copy)
@@ -1038,7 +1038,7 @@
}
gpointer
-mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char **exc_arg)
+mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, char **exc_arg)
{
MonoImage *image = method->klass->image;
MonoMethodPInvoke *piinfo = (MonoMethodPInvoke *)method;
@@ -1193,11 +1193,10 @@
mono_trace (G_LOG_LEVEL_WARNING, MONO_TRACE_DLLIMPORT,
"DllImport unable to load library '%s'.",
error_msg);
- g_free (error_msg);
if (exc_class) {
*exc_class = "DllNotFoundException";
- *exc_arg = new_scope;
+ *exc_arg = g_strconcat (new_scope, " ", error_msg, NULL);;
}
return NULL;
}
@@ -1298,7 +1297,7 @@
g_free (error_msg);
if (exc_class) {
*exc_class = "EntryPointNotFoundException";
- *exc_arg = import;
+ *exc_arg = g_strdup (import);
}
return NULL;
}
Index: metadata/loader.h
===================================================================
--- metadata/loader.h (revision 76089)
+++ metadata/loader.h (working copy)
@@ -63,7 +63,7 @@
mono_dllmap_insert (MonoImage *assembly, const char *dll, const char *func, const char *tdll, const char *tfunc);
gpointer
-mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, const char **exc_arg);
+mono_lookup_pinvoke_call (MonoMethod *method, const char **exc_class, char **exc_arg);
void
mono_method_get_param_names (MonoMethod *method, const char **names);
Index: metadata/marshal.c
===================================================================
--- metadata/marshal.c (revision 76089)
+++ metadata/marshal.c (working copy)
@@ -8466,9 +8466,9 @@
mono_mb_emit_exception (mb, exc_class, exc_arg);
csig = signature_dup (method->klass->image, sig);
csig->pinvoke = 0;
- res = mono_mb_create_and_cache (cache, method,
- mb, csig, csig->param_count + 16);
+ res = mono_mb_create_and_cache (cache, method, mb, csig, csig->param_count + 16);
mono_mb_free (mb);
+ g_free (exc_arg);
return res;
}
Index: metadata/icall.c
===================================================================
--- metadata/icall.c (revision 76089)
+++ metadata/icall.c (working copy)
@@ -6297,13 +6297,16 @@
static void
prelink_method (MonoMethod *method)
{
- const char *exc_class, *exc_arg;
+ const char *exc_class;
+ char *exc_arg;
+
if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
return;
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 ) );
+ MonoException *exc = mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg);
+ g_free (exc_arg);
+ mono_raise_exception(exc);
}
/* create the wrapper, too? */
}
Index: mini/mini.c
===================================================================
--- mini/mini.c (revision 76089)
+++ mini/mini.c (working copy)
@@ -10753,11 +10753,11 @@
if (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL)
mono_lookup_pinvoke_call (method, NULL, NULL);
}
- nm = mono_marshal_get_native_wrapper (method);
- return mono_get_addr_from_ftnptr (mono_compile_method (nm));
+ nm = mono_marshal_get_native_wrapper (method);
+ return mono_get_addr_from_ftnptr (mono_compile_method (nm));
- //if (mono_debug_format != MONO_DEBUG_FORMAT_NONE)
- //mono_debug_add_wrapper (method, nm);
+ //if (mono_debug_format != MONO_DEBUG_FORMAT_NONE)
+ //mono_debug_add_wrapper (method, nm);
} else if ((method->iflags & METHOD_IMPL_ATTRIBUTE_RUNTIME)) {
const char *name = method->name;
MonoMethod *nm;
_______________________________________________
Mono-list maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-list