That is the point. I don&#39;t want to do that from a file but from an Assembly (dll).<br><br><div class="gmail_quote">2009/1/21 Dino Viehland <span dir="ltr">&lt;<a href="mailto:dinov@microsoft.com">dinov@microsoft.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">








<div link="blue" vlink="purple" lang="EN-US">

<div>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">You need to do:</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">eng.ExecuteFile('myfile.py', scope);</span></p>

<p><span style="font-size: 11pt; color: rgb(31, 73, 125);">&nbsp;</span></p>

<div style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; border-width: medium medium medium 1.5pt; padding: 0in 0in 0in 4pt;">

<div>

<div style="border-style: solid none none; border-color: rgb(181, 196, 223) -moz-use-text-color -moz-use-text-color; border-width: 1pt medium medium; padding: 3pt 0in 0in;">

<p><b><span style="font-size: 10pt;">From:</span></b><span style="font-size: 10pt;">
<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a> [mailto:<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com</a>] <b>On
Behalf Of </b>Renaud Durand<br>
<b>Sent:</b> Wednesday, January 21, 2009 7:45 AM<br>
<b>To:</b> <a href="mailto:dody@nomadlife.org" target="_blank">dody@nomadlife.org</a>; Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Calling a Python function (compiled into an
assembly) from C# using delegates.</span></p>

</div>

</div><div><div></div><div class="Wj3C7c">

<p>&nbsp;</p>

<p style="margin-bottom: 12pt;">Ok, but how ?</p>

<div>

<p>2009/1/21 Dody Gunawinata &lt;<a href="mailto:empirebuilder@gmail.com" target="_blank">empirebuilder@gmail.com</a>&gt;</p>

<div>

<p style="margin-bottom: 12pt;">I think you have to import the
function - loading the assembly alone is not enough.</p>

<div>

<div>

<div>

<p>On Wed, Jan 21, 2009 at 5:17 PM, Renaud Durand &lt;<a href="http://renaud.durand.it" target="_blank">renaud.durand.it</a>@<a href="http://gmail.com" target="_blank">gmail.com</a>&gt; wrote:</p>

</div>

</div>

<blockquote style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color rgb(204, 204, 204); border-width: medium medium medium 1pt; padding: 0in 0in 0in 6pt; margin-left: 4.8pt; margin-right: 0in;">


<div>

<div>

<p style="margin-bottom: 12pt;">Hi again,<br>
<br>
I&#39;m trying to call a python function from C#. I found out through a tutorial
how to do it from<br>
a Python source file but I would like to do it from a compiled assembly. Some
elements are missing.<br>
I think it is something like below but this does not work:<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; eng =
Python.CreateEngine()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Assembly
interpreter = Assembly.Load(&quot;interpreter&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
eng.runtime.LoadAssembly(interpreter);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ScriptScope
scope = eng.CreateScope();<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Get the
interpretMapping function<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Func&lt;string, object&gt; interpretMapping;<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
interpretMapping = scope.GetVariable&lt;Func&lt;string,
object&gt;&gt;(&quot;interpretMapping&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ObjectOperations ops = eng.Operations;<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Get the
interpItem returned by function.<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object item
= interpretMapping(&quot;649AC0165011B1E8F726AC54C911000000000000000000000000000000000000&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //Get the
display Method<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; object
method = ops.GetMember(item, &quot;display&quot;);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
ops.Call(method);<br>
<br>
Thank you... Again :-)<br>
<span style="color: rgb(136, 136, 136);"><br>
-- <br>
Renaud Durand<br>
EPITA Student</span></p>

</div>

</div>

<p style="margin-bottom: 12pt;">_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a></p>

</blockquote>

</div>

<p style="margin-bottom: 12pt;"><br>
<br clear="all">
<br>
-- <br>
<a href="http://nomadlife.org" target="_blank">nomadlife.org</a></p>

</div>

<p style="margin-bottom: 12pt;"><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com" target="_blank">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a></p>

</div>

<p><br>
<br clear="all">
<br>
-- <br>
Renaud Durand</p>

</div></div></div>

</div>

</div>


<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br>Renaud Durand<br>