First set of licensing changes
[mono.git] / mono / metadata / attach.c
index 4f5024a72f0bb61a91d78f648b0265e9500b47de..9e54462633cf92da422cb9e8d06a9783b4dae022 100644 (file)
@@ -5,6 +5,7 @@
  *   Zoltan Varga (vargaz@gmail.com)
  *
  * Copyright 2007-2009 Novell, Inc (http://www.novell.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
  */
 
 #include <config.h>
@@ -265,6 +266,7 @@ mono_attach_cleanup (void)
 static int
 mono_attach_load_agent (MonoDomain *domain, char *agent, char *args, MonoObject **exc)
 {
+       MonoError error;
        MonoAssembly *agent_assembly;
        MonoImage *image;
        MonoMethod *method;
@@ -292,9 +294,10 @@ mono_attach_load_agent (MonoDomain *domain, char *agent, char *args, MonoObject
                return 1;
        }
 
-       method = mono_get_method (image, entry, NULL);
+       method = mono_get_method_checked (image, entry, NULL, NULL, &error);
        if (method == NULL){
-               g_print ("The entry point method of assembly '%s' could not be loaded\n", agent);
+               g_print ("The entry point method of assembly '%s' could not be loaded due to %s\n", agent, mono_error_get_message (&error));
+               mono_error_cleanup (&error);
                g_free (agent);
                return 1;
        }
@@ -309,7 +312,8 @@ mono_attach_load_agent (MonoDomain *domain, char *agent, char *args, MonoObject
        g_free (agent);
 
        pa [0] = main_args;
-       mono_runtime_invoke (method, NULL, pa, exc);
+       mono_runtime_try_invoke (method, NULL, pa, exc, &error);
+       mono_error_raise_exception (&error); /* FIXME don't raise here */
 
        return 0;
 }