Re: mono_method_desc_search_in_image problem, and some question...

R Zaghi <[email protected]> Tue, 13 Feb 2018 11:04:31 +0000
Newsgroups gmane.comp.gnome.mono.devel
Message-ID <CAFLMc5ssLDo7970WH7Qyb4xAn0uCMx0J4owhTMGxozr7OsbxXw@mail.gmail.com>
--===============8971646380456142038==
Content-Type: multipart/alternative; boundary="00000000000023efe8056515f6ff"

--00000000000023efe8056515f6ff
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

If this is actually a problem with a library like mono then it sounds like
a caching problem. If you build mono from source then it's easier to look
into this...

Compare your code with this example. In the example, the .dll assembly is
re-loaded in a loop. You can see the clean up portion and the shutdown or
initialisation portions too:

https://github.com/ramin-zaghi/mono-embedding

Regarding how to compile code at runtime without a system() call, you can
use CodeDom (look it up) to compile from files, or in a mono-specific way
use Mono Compiler Service (e.g the Evaluator and CompilerContext classes -
google them) which allow you to evaluate partial expressions/statements/etc=
.

I use both depending on situation and they work pretty well. Roslyn is
apparently another option but let's not go there :)

R.





On Tue, 13 Feb 2018 at 16:17, pierre <[email protected]> wrote:

> Thanks for the answer.
>
>
> > you 100% sure the old files are all overwritten?
> Yes, I have checked the file time... and also included a
>
> remove(fileName);
>
> to be sure!
>
>
> >There are a couple of different ways to get compiled binary at runtime
> without a system() call
> Which ones?
>
> I have tried something:
> calling mono_image_open_from_data_with_name and mono_assembly_load_from_f=
ull
> with a different file name on every compile and it is working!!!
>
> so, the following code is not reloading properly:
>
> monoEngine->fileName =3D strdup("code.dll");
>
>
> monoEngine->image =3D mono_image_open_from_data_with_name(data, dataLen,
>                                                           TRUE /* copy
> data */,
>                                                           &status,
>                                                           FALSE /* ref
> only */,
>
> monoEngine->fileName);
> if (status !=3D MONO_IMAGE_OK || monoEngine->image =3D=3D NULL)
> {
> }
> monoEngine->assembly =3D mono_assembly_load_from_full(monoEngine->image,
>
> monoEngine->fileName,
>                                                       &status, FALSE);
> if (status !=3D MONO_IMAGE_OK || monoEngine->assembly =3D=3D NULL)
> {
> }
>
>
> but, the same with a different file name on every run (only the
> monoEngine->fileName creation differ) is working:
>
> static int version =3D 1;
> ...
>
> sprintf(monoEngine->fileName,  "code%03d.dll", version);
> version ++;
>
>
> monoEngine->image =3D mono_image_open_from_data_with_name(data, dataLen,
>                                                           TRUE /* copy
> data */,
>                                                           &status,
>                                                           FALSE /* ref
> only */,
>
> monoEngine->fileName);
> if (status !=3D MONO_IMAGE_OK || monoEngine->image =3D=3D NULL)
> {
> }
> monoEngine->assembly =3D mono_assembly_load_from_full(monoEngine->image,
>
> monoEngine->fileName,
>                                                       &status, FALSE);
> if (status !=3D MONO_IMAGE_OK || monoEngine->assembly =3D=3D NULL)
> {
> }
>
> Is there a wait to be introduced after a mono_domain_unload? It is like
> doing mono_domain_unload, mono_image_open_from_data_with_name and mono_as=
sembly_load_from_full
> with the same file name is detected and the unload is not performed....
>
>
> > This is more likely to be a problem outside of mono.
> I do agree... but I am running out of idea on why!!!
>
>
> and for mono_method_desc_search_in_image? is it bug?
>
>
> Pierre
>
>
> On 13/02/2018 07:15, R Zaghi wrote:
>
> 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 ha=
ve
> 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=E2=84=A2 | User Interface Technology*
> St John's Innovation Centre,
> Cowley Road,
> Cambridge,
> CB4 0WS, UK
> *E*: [email protected]
> *T*: +44 1223 421 311 <+44%201223%20421311>
> http://linkedin.com/in/raminzaghi
>
>
>
> On Tue, 13 Feb 2018 at 01:27, pierre <[email protected]> wrote=
:
>
>> Hi,
>>
>> I am trying to embed mono... and I ran into a problem with the code:
>>
>> monoMethodDesc =3D mono_method_desc_new("Script:Main", 0);
>> method =3D 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 =3D mono_method_desc_new("Script2:Main", 0);
>>
>>
>> Am i doing something wrong or is this a bug? It seem that mono_method_de=
sc_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:Mai=
n"
>> 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 reloa=
d
>> 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 =3D mono_domain_set(rootDomain, FALSE);
>> mono_domain_unload(monoEngine->domain);
>> monoEngine->domain =3D mono_domain_create_appdomain("ScriptEngine-sub",
>> NULL);
>>
>> data =3D readFile(f, &dataLen);
>> fclose(f);
>> monoEngine->image =3D mono_image_open_from_data_with_name(data, dataLen,
>>                                                           TRUE /* copy
>> data */,
>>                                                           &status,
>>                                                           FALSE /* ref
>> only */,
>>
>> monoEngine->fileName);
>>   free(data);
>>   if (status !=3D MONO_IMAGE_OK || monoEngine->image =3D=3D NULL)
>>   {
>>     return FALSE;
>>   }
>>
>>     // load the assembly
>>   monoEngine->assembly =3D mono_assembly_load_from_full(monoEngine->imag=
e,
>>
>> monoEngine->fileName,
>>                                                       &status, FALSE);
>>   if (status !=3D MONO_IMAGE_OK || monoEngine->assembly =3D=3D 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 t=
o
>> 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  -  [email protected]://lists.dot.net/mailm=
an/listinfo/mono-list
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> [email protected]
>> http://lists.dot.net/mailman/listinfo/mono-devel-list
>>
> --
>
>
>
> Ramin Zaghi
>
> *Mosaic3DX=E2=84=A2 | User Interface Technology*
> St John's Innovation Centre,
> Cowley Road,
> Cambridge,
> CB4 0WS, UK
> *E*: [email protected]
> *T*: +44 1223 421 311
> http://linkedin.com/in/raminzaghi
>
>
> --



Ramin Zaghi

*Mosaic3DX=E2=84=A2 | User Interface Technology*
St John's Innovation Centre,
Cowley Road,
Cambridge,
CB4 0WS, UK
*E*: [email protected]
*T*: +44 1223 421 311
http://linkedin.com/in/raminzaghi

--00000000000023efe8056515f6ff
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div><div dir=3D"auto">If this is actually a problem with a library like mo=
no then it sounds like a caching problem. If you build mono from source the=
n it&#39;s easier to look into this...</div><div dir=3D"auto"><br></div><di=
v dir=3D"auto">Compare your code with this example. In the example, the .dl=
l assembly is re-loaded in a loop. You can see the clean up portion and the=
 shutdown or initialisation portions too:</div><div dir=3D"auto"><br></div>=
<div dir=3D"auto"><a href=3D"https://github.com/ramin-zaghi/mono-embedding"=
>https://github.com/ramin-zaghi/mono-embedding</a><br></div><div dir=3D"aut=
o"><br></div><div dir=3D"auto">Regarding how to compile code at runtime wit=
hout a system() call, you can use CodeDom (look it up) to compile from file=
s, or in a mono-specific way use Mono Compiler Service (e.g the Evaluator a=
nd CompilerContext classes - google them) which allow you to evaluate parti=
al expressions/statements/etc.</div><div dir=3D"auto"><br></div><div dir=3D=
"auto">I use both depending on situation and they work pretty well. Roslyn =
is apparently another option but let&#39;s not go there :)</div><div dir=3D=
"auto"><br></div><div dir=3D"auto">R.</div><div dir=3D"auto"><br></div><div=
 dir=3D"auto"><br></div><div dir=3D"auto"><br></div><div dir=3D"auto"><br><=
/div><br><div class=3D"gmail_quote"><div>On Tue, 13 Feb 2018 at 16:17, pier=
re &lt;<a href=3D"mailto:[email protected]">pierre.saunier@ppmod=
eler.com</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D=
"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 =20
   =20
 =20
  <div text=3D"#000000" bgcolor=3D"#FFFFFF">
    <div class=3D"m_-2028573316465613946moz-cite-prefix">Thanks for the ans=
wer.</div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF"><div class=3D"m_-=
2028573316465613946moz-cite-prefix"><br>
      <br>
      &gt; you 100% sure the old files are all overwritten? <br></div></div=
><div text=3D"#000000" bgcolor=3D"#FFFFFF"><div class=3D"m_-202857331646561=
3946moz-cite-prefix">
      Yes, I have checked the file time... and also included a<br>
      <blockquote><tt>remove(fileName);</tt><br>
      </blockquote>
      to be sure!</div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF"><div=
 class=3D"m_-2028573316465613946moz-cite-prefix"><br>
      <br>
      &gt;There are a couple of different ways to get compiled binary at
      runtime without a system() call <br></div></div><div text=3D"#000000"=
 bgcolor=3D"#FFFFFF"><div class=3D"m_-2028573316465613946moz-cite-prefix">
      Which ones? <br>
      <br>
      I have tried something:=C2=A0 <br>
      calling <tt>mono_image_open_from_data_with_name</tt> and <tt>mono_ass=
embly_load_from_full
      </tt>with a different file name on every compile and it is
      working!!!<br>
      <br>
      so, the following code is not reloading properly:<br>
      <blockquote><tt>monoEngine-&gt;fileName =3D strdup(&quot;code.dll&quo=
t;);</tt></blockquote></div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF"=
><div class=3D"m_-2028573316465613946moz-cite-prefix"><blockquote><br>
        <tt>monoEngine-&gt;image =3D
          mono_image_open_from_data_with_name(data, dataLen, </tt><br>
        <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          TRUE /* copy data */, </tt><br>
        <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          &amp;status, </tt><br>
        <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          FALSE /* ref only */, </tt><br>
        <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          monoEngine-&gt;fileName);</tt><br>
        <tt>if (status !=3D MONO_IMAGE_OK || monoEngine-&gt;image =3D=3D NU=
LL)</tt><br>
        <tt>{</tt><br>
        <tt>}</tt><br>
        <tt>monoEngine-&gt;assembly =3D
          mono_assembly_load_from_full(monoEngine-&gt;image, </tt><br>
        <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          monoEngine-&gt;fileName, </tt><br>
        <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          &amp;status, FALSE);</tt><br>
        <tt>if (status !=3D MONO_IMAGE_OK || monoEngine-&gt;assembly =3D=3D
          NULL)</tt><br>
        <tt>{</tt><br>
        <tt>}</tt><br>
      </blockquote></div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF"><d=
iv class=3D"m_-2028573316465613946moz-cite-prefix"><blockquote></blockquote=
>
      <br>
      but, the same with a different file name on every run (only the <tt>m=
onoEngine-&gt;fileName</tt>
      creation differ<tt>) is working</tt>:<br>
      <blockquote><tt>static int version =3D 1;</tt><br>
        <tt>...</tt><br>
        <br>
        <tt>sprintf(monoEngine-&gt;fileName,=C2=A0 &quot;code%03d.dll&quot;=
, version);</tt><br>
        <tt>version ++;</tt></blockquote></div></div><div text=3D"#000000" =
bgcolor=3D"#FFFFFF"><div class=3D"m_-2028573316465613946moz-cite-prefix"><b=
lockquote><br>
        <tt>monoEngine-&gt;image =3D
          mono_image_open_from_data_with_name(data, dataLen, </tt><br>
        <tt>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 TRUE
          /* copy data */, </tt><br>
        <tt>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          &amp;status, </tt><br>
        <tt>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          FALSE /* ref only */, </tt><br>
        <tt>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          monoEngine-&gt;fileName);</tt><br>
        <tt>
          if (status !=3D MONO_IMAGE_OK || monoEngine-&gt;image =3D=3D NULL=
)</tt><br>
        <tt>
          {</tt><br>
        <tt>
          }</tt><br>
        <tt>
          monoEngine-&gt;assembly =3D
          mono_assembly_load_from_full(monoEngine-&gt;image, </tt><br>
        <tt>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          monoEngine-&gt;fileName, </tt><br>
        <tt>
          =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
          &amp;status, FALSE);</tt><br>
        <tt>
          if (status !=3D MONO_IMAGE_OK || monoEngine-&gt;assembly =3D=3D
          NULL)</tt><br>
        <tt>
          {</tt><br>
        <tt>
          }</tt><br>
      </blockquote></div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF"><d=
iv class=3D"m_-2028573316465613946moz-cite-prefix"><blockquote></blockquote=
>
      Is there a wait to be introduced after a mono_domain_unload? It is
      like doing <tt>mono_domain_unload,
        mono_image_open_from_data_with_name and </tt><tt>mono_assembly_load=
_from_full
      </tt>with the same file name is detected <tt>and the unload is
        not performed....<br>
      </tt></div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF"><div class=
=3D"m_-2028573316465613946moz-cite-prefix"><tt>=C2=A0</tt><br>
      <br>
      &gt; This is more likely to be a problem outside of mono.<br></div></=
div><div text=3D"#000000" bgcolor=3D"#FFFFFF"><div class=3D"m_-202857331646=
5613946moz-cite-prefix">
      I do agree... but I am running out of idea on why!!!<br>
      <br>
      <br>
      and for mono_method_desc_search_in_image? is it bug?</div></div><div =
text=3D"#000000" bgcolor=3D"#FFFFFF"><div class=3D"m_-2028573316465613946mo=
z-cite-prefix"><br>
      <br>
      Pierre</div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF"><div clas=
s=3D"m_-2028573316465613946moz-cite-prefix"><br>
      <br>
      On 13/02/2018 07:15, R Zaghi wrote:<br>
    </div></div><div text=3D"#000000" bgcolor=3D"#FFFFFF">
    <blockquote type=3D"cite">
      <div>
        <div>
          <div dir=3D"auto">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?</di=
v>
          <div dir=3D"auto"><br>
          </div>
          <div dir=3D"auto">This is more likely to be a problem outside of
            mono.</div>
          <div dir=3D"auto"><br>
          </div>
          <div dir=3D"auto">Ramin</div>
        </div>
      </div>
      <div>
        <div>
          <div dir=3D"auto"><br>
          </div>
          <div dir=3D"auto"><br>
          </div>
          <div dir=3D"auto"><br>
          </div>
          <div dir=3D"auto"><br>
          </div>
          <div dir=3D"auto">
            <div style=3D"color:rgb(117,117,117);word-spacing:1px;font-size=
:1rem;line-height:normal!important">Ramin
              Zaghi</div>
            <div style=3D"color:rgb(117,117,117);word-spacing:1px;line-heig=
ht:normal!important"><br style=3D"line-height:normal!important">
              <div style=3D"line-height:normal!important"><img src=3D"https=
://drive.google.com/uc?id=3D0B3xiwa7kf1uwRlYxenBFM1o2NEk&amp;export=3Ddownl=
oad" style=3D"line-height:normal!important"><b style=3D"line-height:normal!=
important;font-size:1rem">Mosaic3DX=E2=84=A2
                  |=C2=A0<font style=3D"line-height:normal!important;font-s=
ize:0.625rem">User
                    Interface Technology</font></b></div>
              <div style=3D"line-height:normal!important">
                <div style=3D"line-height:normal!important;font-size:0.8125=
rem">St
                  John&#39;s Innovation Centre,</div>
                <div style=3D"line-height:normal!important;font-size:0.8125=
rem">Cowley
                  Road,</div>
                <div style=3D"line-height:normal!important;font-size:0.8125=
rem">Cambridge,</div>
                <div style=3D"line-height:normal!important;font-size:0.8125=
rem">CB4
                  0WS, UK<b style=3D"line-height:normal!important"><br styl=
e=3D"line-height:normal!important">
                  </b></div>
                <div style=3D"line-height:normal!important;font-size:0.8125=
rem"><b style=3D"line-height:normal!important;font-size:0.8125rem">E</b>:<b=
 style=3D"line-height:normal!important">=C2=A0</b><a href=3D"mailto:rzaghi@=
mosaic3dx.com" style=3D"font-size:0.8125rem;line-height:normal!important" t=
arget=3D"_blank">[email protected]</a></div>
                <div style=3D"line-height:normal!important;font-size:0.8125=
rem"><b style=3D"line-height:normal!important;font-size:0.8125rem">T</b>:=
=C2=A0<a href=3D"tel:+44%201223%20421311" value=3D"+441223421311" style=3D"=
font-size:0.8125rem;line-height:normal!important" target=3D"_blank">+44 122=
3 421 311</a></div>
              </div>
              <div style=3D"line-height:normal!important"><font style=3D"li=
ne-height:normal!important" size=3D"2"><a href=3D"http://linkedin.com/in/ra=
minzaghi" style=3D"font-size:0.8125rem;line-height:normal!important" target=
=3D"_blank">http://linkedin.com/in/raminzaghi</a></font></div>
              <div style=3D"line-height:normal!important" dir=3D"auto"><br>
              </div>
            </div>
          </div>
          <div dir=3D"auto"><br>
          </div>
          <br>
          <div class=3D"gmail_quote">
            <div>On Tue, 13 Feb 2018 at 01:27, pierre &lt;<a href=3D"mailto=
:[email protected]" target=3D"_blank">[email protected]=
om</a>&gt;
              wrote:<br>
            </div>
            <blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex">
              <div text=3D"#000000" bgcolor=3D"#FFFFFF">
                <div class=3D"m_-2028573316465613946m_5069017230163669461m_=
-3097578244239708022moz-text-html" lang=3D"x-western"> Hi,<br>
                  <br>
                  I am trying to embed mono... and I ran into a problem
                  with the code: <br>
                  <blockquote><tt>monoMethodDesc =3D
                      mono_method_desc_new(&quot;Script:Main&quot;, 0);</tt=
><tt><br>
                    </tt><tt>method =3D
                      mono_method_desc_search_in_image(monoMethodDesc,
                      monoEngine-&gt;image);</tt><br>
                  </blockquote>
                  <br>
                  It is returning a method on the cs code:<br>
                  <blockquote><tt>public class Script</tt><tt><br>
                    </tt><tt>{</tt><tt><br>
                    </tt><tt>=C2=A0 static public void Main ()</tt><tt><br>
                    </tt><tt>=C2=A0 {</tt><tt><br>
                    </tt><tt>=C2=A0=C2=A0=C2=A0 ScriptEngine.report(&quot;-=
-Main Called &quot;);</tt><tt><br>
                    </tt><tt>=C2=A0 }</tt><tt><br>
                    </tt><tt>}</tt><br>
                  </blockquote>
                  <br>
                  but it is also returning a method on the cs code (with
                  the wrong class name):<br>
                  <br>
                  <blockquote><tt>public class Script<b>2</b></tt><tt><br>
                    </tt><tt> {</tt><tt><br>
                    </tt><tt> =C2=A0 static public void Main ()</tt><tt><br=
>
                    </tt><tt> =C2=A0 {</tt><tt><br>
                    </tt><tt> =C2=A0=C2=A0=C2=A0 ScriptEngine.report(&quot;=
--Main Called &quot;);</tt><tt><br>
                    </tt><tt> =C2=A0 }</tt><tt><br>
                    </tt><tt> }</tt><br>
                  </blockquote>
                  while it should only return for:<br>
                  <blockquote><tt>monoMethodDesc =3D
                      mono_method_desc_new(&quot;Script2:Main&quot;, 0);</t=
t><br>
                  </blockquote>
                  <tt> </tt><br>
                  Am i doing something wrong or is this a bug? It seem
                  that <tt>mono_method_desc_search_in_image </tt>is
                  returning a value if the actual class name is starting
                  with the given=C2=A0 class name.... so, the same method i=
s
                  returned if I look for &quot;Script:Main&quot; but the de=
clared
                  class is &quot;Script:Main&quot;, &quot;Script_test:Main&=
quot; or
                  &quot;Script2:Main&quot;...<br>
                  <br>
                  and a question:<br>
                  is there a way to know if mono_domain_unload was
                  successful or not? <br>
                  <br>
                  I am creating an app domain per script so that I can
                  recompile and reload the script at will... <br>
                  I do not detect any error, but the new script seems
                  not to replace the old one...<br>
                  Basically, I am doing:<br>
                  <blockquote><tt>res =3D mono_domain_set(rootDomain,
                      FALSE);</tt><br>
                    <tt>mono_domain_unload(monoEngine-&gt;domain);</tt><br>
                    <tt>monoEngine-&gt;domain =3D
                      mono_domain_create_appdomain(&quot;ScriptEngine-sub&q=
uot;,
                      NULL);</tt><br>
                    <br>
                    <tt>data =3D readFile(f, &amp;dataLen);</tt><br>
                    <tt>fclose(f);</tt><br>
                    <tt>monoEngine-&gt;image =3D
                      mono_image_open_from_data_with_name(data, dataLen,
                    </tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
                      TRUE /* copy data */, </tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
                      &amp;status, </tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
                      FALSE /* ref only */, </tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
                      monoEngine-&gt;fileName);</tt><br>
                    <tt>=C2=A0 free(data);</tt><br>
                    <tt>=C2=A0 if (status !=3D MONO_IMAGE_OK ||
                      monoEngine-&gt;image =3D=3D NULL)</tt><br>
                    <tt>=C2=A0 {</tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0 return FALSE;</tt><br>
                    <tt>=C2=A0 }</tt><br>
                    <br>
                    <tt>=C2=A0=C2=A0=C2=A0 // load the assembly</tt><br>
                    <tt>=C2=A0 monoEngine-&gt;assembly =3D
                      mono_assembly_load_from_full(monoEngine-&gt;image,
                    </tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
                      monoEngine-&gt;fileName, </tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0
                      &amp;status, FALSE);</tt><br>
                    <tt>=C2=A0 if (status !=3D MONO_IMAGE_OK ||
                      monoEngine-&gt;assembly =3D=3D NULL)</tt><br>
                    <tt>=C2=A0 {</tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0 mono_image_close(monoEngine-&gt;=
image);</tt><br>
                    <tt>=C2=A0=C2=A0=C2=A0 return FALSE;</tt><br>
                    <tt>=C2=A0 }</tt><br>
                  </blockquote>
                  but it does not seem to work. The code that runs is
                  always the first loaded one!! <br>
                  <br>
                  I also added the following code to my engine:<br>
                  <blockquote><tt>mono_trace_set_log_handler(monoLogCallbac=
k,
                      NULL);</tt><br>
                    <tt>mono_trace_set_print_handler(monoPrintCallback);</t=
t><br>
                    <tt>mono_trace_set_printerr_handler(monoPrintCallback);=
</tt><br>
                    <tt>mono_trace_set_level_string (&quot;debug&quot;);</t=
t><br>
                  </blockquote>
                  <br>
                  but it is reporting debug info only on the first
                  run... is there a way to having it working on every
                  run?<br>
                  <br>
                  Lastly, Is there a way to compile cs source without
                  launching a <br>
                  <blockquote><tt>system(&quot;msc.code.cs -target:library&=
quot;);</tt><br>
                  </blockquote>
                  thanks in advance<br>
                  <br>
                  Pierre<br>
                  <br>
                </div>
                <br>
                <fieldset class=3D"m_-2028573316465613946m_5069017230163669=
461m_-3097578244239708022mimeAttachmentHeader"></fieldset>
                <br>
                <div class=3D"m_-2028573316465613946m_5069017230163669461m_=
-3097578244239708022moz-text-plain" style=3D"font-family:-moz-fixed;font-si=
ze:14px" lang=3D"x-unicode">
                  <pre>_______________________________________________
Mono-list maillist  -  <a class=3D"m_-2028573316465613946m_5069017230163669=
461m_-3097578244239708022moz-txt-link-abbreviated" href=3D"mailto:Mono-list=
@lists.dot.net" target=3D"_blank">[email protected]</a>
<a class=3D"m_-2028573316465613946m_5069017230163669461m_-30975782442397080=
22moz-txt-link-freetext" href=3D"http://lists.dot.net/mailman/listinfo/mono=
-list" target=3D"_blank">http://lists.dot.net/mailman/listinfo/mono-list</a=
>
</pre>
                </div>
              </div>
              _______________________________________________<br>
              Mono-devel-list mailing list<br>
              <a href=3D"mailto:[email protected]" target=3D"_b=
lank">[email protected]</a><br>
              <a href=3D"http://lists.dot.net/mailman/listinfo/mono-devel-l=
ist" rel=3D"noreferrer" target=3D"_blank">http://lists.dot.net/mailman/list=
info/mono-devel-list</a><br>
            </blockquote>
          </div>
        </div>
      </div>
      <div>-- <br>
      </div>
      <div class=3D"m_-2028573316465613946gmail_signature" data-smartmail=
=3D"gmail_signature">
        <div>
          <div>
            <div>
              <div>
                <div>
                  <div>
                    <div>
                      <div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div><br>
                        </div>
                        <div>Ramin Zaghi</div>
                        <div><br>
                          <div><img src=3D"https://drive.google.com/uc?id=
=3D0B3xiwa7kf1uwRlYxenBFM1o2NEk&amp;export=3Ddownload"><b>Mosaic3DX=E2=84=
=A2 | <font size=3D"1">User Interface Technology</font></b></div>
                          <div>
                            <div style=3D"font-size:small">St John&#39;s
                              Innovation Centre,</div>
                            <div style=3D"font-size:small">Cowley Road,</di=
v>
                            <div style=3D"font-size:small">Cambridge,</div>
                            <div style=3D"font-size:small">CB4 0WS, UK<b><b=
r>
                              </b></div>
                            <div style=3D"font-size:small"><b>E</b>:<b>=C2=
=A0</b><a href=3D"mailto:[email protected]" target=3D"_blank">rzaghi@mos=
aic3dx.com</a></div>
                            <div style=3D"font-size:small"><b>T</b>:=C2=A0+=
44
                              1223 421 311</div>
                          </div>
                          <div><font size=3D"2"><a href=3D"http://linkedin.=
com/in/raminzaghi" target=3D"_blank">http://linkedin.com/in/raminzaghi</a><=
/font></div>
                          <div><font size=3D"2"><br>
                            </font></div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <p><br>
    </p>
  </div></blockquote></div></div><div dir=3D"ltr">-- <br></div><div class=
=3D"gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><d=
iv><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div d=
ir=3D"ltr"><br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></div>=
<div dir=3D"ltr">Ramin Zaghi</div><div dir=3D"ltr"><br><div><img src=3D"htt=
ps://drive.google.com/uc?id=3D0B3xiwa7kf1uwRlYxenBFM1o2NEk&amp;export=3Ddow=
nload"><b>Mosaic3DX=E2=84=A2 | <font size=3D"1">User Interface Technology</=
font></b></div><div><div style=3D"font-size:small">St John&#39;s Innovation=
 Centre,</div><div style=3D"font-size:small">Cowley Road,</div><div style=
=3D"font-size:small">Cambridge,</div><div style=3D"font-size:small">CB4 0WS=
, UK<b><br></b></div><div style=3D"font-size:small"><b>E</b>:<b>=C2=A0</b><=
a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]=
om</a></div><div style=3D"font-size:small"><b>T</b>:=C2=A0+44 1223 421 311<=
/div></div><div><font size=3D"2"><a href=3D"http://linkedin.com/in/raminzag=
hi" target=3D"_blank">http://linkedin.com/in/raminzaghi</a></font></div><di=
v><font size=3D"2"><br></font></div></div></div></div></div></div></div></d=
iv></div></div></div>

--00000000000023efe8056515f6ff--

--===============8971646380456142038==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KTW9uby1kZXZl
bC1saXN0IG1haWxpbmcgbGlzdApNb25vLWRldmVsLWxpc3RAbGlzdHMuZG90Lm5ldApodHRwOi8v
bGlzdHMuZG90Lm5ldC9tYWlsbWFuL2xpc3RpbmZvL21vbm8tZGV2ZWwtbGlzdAo=

--===============8971646380456142038==--