Re: mono_method_desc_search_in_image problem, and some question...
R Zaghi <[email protected]> Tue, 13 Feb 2018 06:15:17 +0000
| Newsgroups | gmane.comp.gnome.mono.devel |
|---|---|
| Message-ID | <CAFLMc5v3aT2-C22k3XV2vsc_ByieY_t-LTLpZSM-GOZwkQ3xWA@mail.gmail.com> |
--===============4175256958387920961== Content-Type: multipart/alternative; boundary="f403045c7d52c70279056511eb0f" --f403045c7d52c70279056511eb0f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable 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=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_des= c_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 ol= d > 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->image= , > > 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 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 - [email protected]://lists.dot.net/mailma= n/listinfo/mono-list > > _______________________________________________ > Mono-devel-list mailing list > [email protected] > http://lists.dot.net/mailman/listinfo/mono-devel-list > --=20 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 --f403045c7d52c70279056511eb0f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div><div><div dir=3D"auto">I think we need to know a bit more about what y= ou are doing in the code exactly but as a quick first guess if you are reco= mpiling 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 syst= em() call then have you tried two separate calls with two parallel binaries= loaded as a start to debug your code?</div><div dir=3D"auto"><br></div><di= v dir=3D"auto">This is more likely to be a problem outside of mono.</div><d= iv dir=3D"auto"><br></div><div dir=3D"auto">Ramin</div></div></div><div><di= v><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 dir=3D"ltr" s= tyle=3D"color:rgb(117,117,117);word-spacing:1px;font-size:1rem;line-height:= normal!important">Ramin Zaghi</div><div dir=3D"ltr" style=3D"color:rgb(117,= 117,117);word-spacing:1px;line-height:normal!important"><br style=3D"line-h= eight:normal!important"><div style=3D"line-height:normal!important"><img sr= c=3D"https://drive.google.com/uc?id=3D0B3xiwa7kf1uwRlYxenBFM1o2NEk&expo= rt=3Ddownload" style=3D"line-height: normal !important; overflow-wrap: brea= k-word !important;"><b style=3D"line-height:normal!important;font-size:1rem= ">Mosaic3DX=E2=84=A2 |=C2=A0<font style=3D"line-height:normal!important;fon= t-size:0.625rem">User Interface Technology</font></b></div><div style=3D"li= ne-height:normal!important"><div style=3D"line-height:normal!important;font= -size:0.8125rem">St John's Innovation Centre,</div><div style=3D"line-h= eight:normal!important;font-size:0.8125rem">Cowley Road,</div><div style=3D= "line-height:normal!important;font-size:0.8125rem">Cambridge,</div><div sty= le=3D"line-height:normal!important;font-size:0.8125rem">CB4 0WS, UK<b style= =3D"line-height:normal!important"><br style=3D"line-height:normal!important= "></b></div><div style=3D"line-height:normal!important;font-size:0.8125rem"= ><b style=3D"line-height:normal!important;font-size:0.8125rem">E</b>:<b sty= le=3D"line-height:normal!important">=C2=A0</b><a href=3D"mailto:rzaghi@mosa= ic3dx.com" target=3D"_blank" style=3D"font-size:0.8125rem;line-height:norma= l!important">[email protected]</a></div><div style=3D"line-height:normal= !important;font-size:0.8125rem"><b style=3D"line-height:normal!important;fo= nt-size:0.8125rem">T</b>:=C2=A0<a href=3D"tel:+44%201223%20421311" value=3D= "+441223421311" target=3D"_blank" style=3D"font-size:0.8125rem;line-height:= normal!important">+44 1223 421 311</a></div></div><div style=3D"line-height= :normal!important"><font size=3D"2" style=3D"line-height:normal!important">= <a href=3D"http://linkedin.com/in/raminzaghi" target=3D"_blank" style=3D"fo= nt-size:0.8125rem;line-height:normal!important">http://linkedin.com/in/rami= nzaghi</a></font></div><div style=3D"line-height:normal!important" dir=3D"a= uto"><br></div></div></div><div dir=3D"auto"><br></div><br><div class=3D"gm= ail_quote"><div>On Tue, 13 Feb 2018 at 01:27, pierre <<a href=3D"mailto:= [email protected]" target=3D"_blank">[email protected]= m</a>> 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"> <pre></pre> <div class=3D"m_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("Script:Main", 0);</tt><tt><br> </tt><tt>method =3D mono_method_desc_search_in_image(monoMethodDesc, monoEngine->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("--Main Called= ");</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("--Main Calle= d ");</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("Script2:Main", 0);</tt><br> </blockquote> <tt> </tt><br> Am i doing something wrong or is this a bug? It seem that <tt>mono_me= thod_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 is returned i= f I look for "Script:Main" but the declared class is "Sc= ript:Main", "Script_test:Main" or "Script2:Main"...<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->domain);</tt><br> <tt>monoEngine->domain =3D mono_domain_create_appdomain("ScriptEngine-sub", NULL);= </tt><br> <br> <tt>data =3D readFile(f, &dataLen);</tt><br> <tt>fclose(f);</tt><br> <tt>monoEngine->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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>=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->assembly =3D mono_assembly_load_from_full(monoEngine->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->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 &status, FALSE);</tt><br> <tt>=C2=A0 if (status !=3D MONO_IMAGE_OK || monoEngine->assembly= =3D=3D NULL)</tt><br> <tt>=C2=A0 {</tt><br> <tt>=C2=A0=C2=A0=C2=A0 mono_image_close(monoEngine->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(monoLogCallback, NULL);</t= t><br> <tt>mono_trace_set_print_handler(monoPrintCallback);</tt><br> <tt>mono_trace_set_printerr_handler(monoPrintCallback);</tt><br> <tt>mono_trace_set_level_string ("debug");</tt><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("msc.code.cs -target:library");</tt>= <br> </blockquote> thanks in advance<br> <br> Pierre<br> <br> </div> <br> <fieldset class=3D"m_5069017230163669461m_-3097578244239708022mimeAttac= hmentHeader"></fieldset> <br> <div class=3D"m_5069017230163669461m_-3097578244239708022moz-text-plain= " style=3D"font-family:-moz-fixed;font-size:14px" lang=3D"x-unicode"> <pre>_______________________________________________ Mono-list maillist - <a class=3D"m_5069017230163669461m_-3097578244239708= 022moz-txt-link-abbreviated" href=3D"mailto:[email protected]" target= =3D"_blank">[email protected]</a> <a class=3D"m_5069017230163669461m_-3097578244239708022moz-txt-link-freetex= t" href=3D"http://lists.dot.net/mailman/listinfo/mono-list" target=3D"_blan= k">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"_blank">Mono-dev= [email protected]</a><br> <a href=3D"http://lists.dot.net/mailman/listinfo/mono-devel-list" rel=3D"no= referrer" target=3D"_blank">http://lists.dot.net/mailman/listinfo/mono-deve= l-list</a><br> </blockquote></div></div></div><div dir=3D"ltr">-- <br></div><div class=3D"= gmail_signature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div><= div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div dir= =3D"ltr"><br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr"><br></div><d= iv dir=3D"ltr">Ramin Zaghi</div><div dir=3D"ltr"><br><div><img src=3D"https= ://drive.google.com/uc?id=3D0B3xiwa7kf1uwRlYxenBFM1o2NEk&export=3Ddownl= oad"><b>Mosaic3DX=E2=84=A2 | <font size=3D"1">User Interface Technology</fo= nt></b></div><div><div style=3D"font-size:small">St John's Innovation C= entre,</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 hr= ef=3D"mailto:[email protected]" target=3D"_blank">[email protected]</= 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><f= ont size=3D"2"><br></font></div></div></div></div></div></div></div></div><= /div></div></div> --f403045c7d52c70279056511eb0f-- --===============4175256958387920961== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KTW9uby1kZXZl bC1saXN0IG1haWxpbmcgbGlzdApNb25vLWRldmVsLWxpc3RAbGlzdHMuZG90Lm5ldApodHRwOi8v bGlzdHMuZG90Lm5ldC9tYWlsbWFuL2xpc3RpbmZvL21vbm8tZGV2ZWwtbGlzdAo= --===============4175256958387920961==--