[Mono-dev] mono_method_desc_search_in_image problem, and some question...

pierre pierre.saunier at ppmodeler.com
Mon Feb 12 17:26:49 UTC 2018


I am trying to embed mono... and I ran into a problem with the code:

    monoMethodDesc = mono_method_desc_new("Script:Main", 0);
    method = mono_method_desc_search_in_image(monoMethodDesc,

It is returning a method on the cs code:

    public class Script
       static public void Main ()
         ScriptEngine.report("--Main Called ");

but it is also returning a method on the cs code (with the wrong class 

    public class Script*2*
       static public void Main ()
         ScriptEngine.report("--Main Called ");

while it should only return for:

    monoMethodDesc = mono_method_desc_new("Script2:Main", 0);

Am i doing something wrong or is this a bug? It seem that 
mono_method_desc_search_in_image is returning a value if the actual 
class name is starting with the given  class name.... so, the same 
method is returned if I look for "Script:Main" but the declared class is 
"Script:Main", "Script_test:Main" or "Script2:Main"...

and a question:
is there a way to know if mono_domain_unload was successful or not?

I am creating an app domain per script so that I can recompile and 
reload the script at will...
I do not detect any error, but the new script seems not to replace the 
old one...
Basically, I am doing:

    res = mono_domain_set(rootDomain, FALSE);
    monoEngine->domain =
    mono_domain_create_appdomain("ScriptEngine-sub", NULL);

    data = readFile(f, &dataLen);
    monoEngine->image = mono_image_open_from_data_with_name(data, dataLen,
    TRUE /* copy data */,
    FALSE /* ref only */,
       if (status != MONO_IMAGE_OK || monoEngine->image == NULL)
         return FALSE;

         // load the assembly
       monoEngine->assembly =
    &status, FALSE);
       if (status != MONO_IMAGE_OK || monoEngine->assembly == NULL)
         return FALSE;

but it does not seem to work. The code that runs is always the first 
loaded one!!

I also added the following code to my engine:

    mono_trace_set_log_handler(monoLogCallback, NULL);
    mono_trace_set_level_string ("debug");

but it is reporting debug info only on the first run... is there a way 
to having it working on every run?

Lastly, Is there a way to compile cs source without launching a

    system("msc.code.cs -target:library");

thanks in advance


Mono-list maillist  -Mono-list at lists.dot.net

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20180212/9c69a575/attachment.html>

More information about the Mono-devel-list mailing list