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

R Zaghi rzaghi at mosaic3dx.com
Tue Feb 13 06:15:17 UTC 2018


I think we need to know a bit more about what you are doing in the code
exactly but as a quick first guess if you are recompiling using a system()
call then are you 100% sure the old files are all overwritten? There are a
couple of different ways to get compiled binary at runtime without a
system() call which I prefer but if you are using a system() call then have
you tried two separate calls with two parallel binaries loaded as a start
to debug your code?

This is more likely to be a problem outside of mono.

Ramin




Ramin Zaghi

*Mosaic3DX™ | User Interface Technology*
St John's Innovation Centre,
Cowley Road,
Cambridge,
CB4 0WS, UK
*E*: rzaghi at mosaic3dx.com
*T*: +44 1223 421 311 <+44%201223%20421311>
http://linkedin.com/in/raminzaghi



On Tue, 13 Feb 2018 at 01:27, pierre <pierre.saunier at ppmodeler.com> wrote:

> Hi,
>
> 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,
> monoEngine->image);
>
>
> 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
> name):
>
> 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);
> mono_domain_unload(monoEngine->domain);
> monoEngine->domain = mono_domain_create_appdomain("ScriptEngine-sub",
> NULL);
>
> data = readFile(f, &dataLen);
> fclose(f);
> monoEngine->image = mono_image_open_from_data_with_name(data, dataLen,
>                                                           TRUE /* copy
> data */,
>                                                           &status,
>                                                           FALSE /* ref
> only */,
>
> monoEngine->fileName);
>   free(data);
>   if (status != MONO_IMAGE_OK || monoEngine->image == NULL)
>   {
>     return FALSE;
>   }
>
>     // load the assembly
>   monoEngine->assembly = mono_assembly_load_from_full(monoEngine->image,
>
> monoEngine->fileName,
>                                                       &status, FALSE);
>   if (status != MONO_IMAGE_OK || monoEngine->assembly == NULL)
>   {
>     mono_image_close(monoEngine->image);
>     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_print_handler(monoPrintCallback);
> mono_trace_set_printerr_handler(monoPrintCallback);
> 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
>
> Pierre
>
>
>
> _______________________________________________
> Mono-list maillist  -  Mono-list at lists.dot.nethttp://lists.dot.net/mailman/listinfo/mono-list
>
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.dot.net
> http://lists.dot.net/mailman/listinfo/mono-devel-list
>
-- 



Ramin Zaghi

*Mosaic3DX™ | User Interface Technology*
St John's Innovation Centre,
Cowley Road,
Cambridge,
CB4 0WS, UK
*E*: rzaghi at mosaic3dx.com
*T*: +44 1223 421 311
http://linkedin.com/in/raminzaghi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.dot.net/pipermail/mono-devel-list/attachments/20180213/e0a4dc53/attachment-0001.html>


More information about the Mono-devel-list mailing list