<div>Your reference to IronMath.dll indicates that you&#39;re using IronPython 1.x.&nbsp; You can find a relevant hosting example at <a href="http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET">http://www.ironpython.info/index.php/Using_Python_Classes_from_.NET</a></div>

<div>&nbsp;</div>
<div>The hosting interface for IronPython 2 is radically different; an equivalent example can be found at <a href="http://www.ironpython.info/index.php/Hosting_IronPython_2">http://www.ironpython.info/index.php/Hosting_IronPython_2</a>.</div>

<div><br>&nbsp;</div>
<div class="gmail_quote">On Fri, Jun 27, 2008 at 7:51 AM, Bob Rosembob &lt;<a href="mailto:brosembob@yahoo.com">brosembob@yahoo.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">
<div>
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div style="FONT-SIZE: 12pt; FONT-FAMILY: times new roman, new york, times, serif">
<div>Hi there,</div>
<div>&nbsp;</div>
<div>I apologize if this is a duplicate message. I sent this message last night but don&#39;t see it posted. Perhaps I did something wrong and message got lost. </div>
<div>&nbsp;</div>
<div>I need to call Python function from C# to get&nbsp;a value. When&nbsp;I call the script it executes and calculates some value, then I need to call some function to get the result. How do I do that? I have the following snippet of code that seems to execute the script, but I don&#39;t know and can&#39;t find on line, how to call a function and get value back.</div>

<div>&nbsp;</div>
<div>I added references to my project to the following dlls:</div>
<div>- IronPython.dlll</div>
<div>- IronMath.dll</div>
<div>&nbsp;</div>
<div>In the code I&#39;m using the following:</div>
<div><font color="#0000ff" size="2"><font color="#0000ff" size="2">
<p>using</p></font></font><font size="2">IronPython.Runtime;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> 
<p>using</p></font></font><font size="2">IronPython.Runtime.Types;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> 
<p>using</p></font></font><font size="2">IronPython.Runtime.Operations;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> 
<p>using</p></font></font><font size="2">IronPython.Hosting;</font><font color="#0000ff" size="2"><font color="#0000ff" size="2"> 
<p>using</p></font></font><font size="2">IronPython.Modules;</font> 
<p><font size="2"></font>&nbsp;</p>
<p>Here is the code:</p>
<p>&nbsp;</p><font size="2">
<p></p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">PythonEngine</font></font><font size="2"> engine = </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font size="2"> </font><font color="#2b91af" size="2"><font color="#2b91af" size="2">PythonEngine</font></font><font size="2">();</font><font color="#008000" size="2"><font color="#008000" size="2"></font></font><font size="2"> 
<p></p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">EngineModule</font></font><font size="2"> module = engine.CreateModule(</font><font color="#a31515" size="2"><font color="#a31515" size="2">&quot;Test&quot;</font></font><font size="2">, </font><font color="#0000ff" size="2"><font color="#0000ff" size="2">true</font></font><font size="2">); 
<p></p>
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">try</font></font><font size="2"> 
<p>{</p>
<p>&nbsp;&nbsp;&nbsp; engine.ExecuteFile(</p></font><font color="#a31515" size="2"><font color="#a31515" size="2">@&quot;Test\Test.py&quot;</font></font><font size="2">, module); 
<p>}</p>
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">catch</font></font><font size="2"> (</font><font color="#2b91af" size="2"><font color="#2b91af" size="2">Exception</font></font><font size="2"> ex) 
<p>{</p>
<p></p></font><font color="#2b91af" size="2"><font color="#2b91af" size="2">&nbsp;&nbsp;&nbsp; Console</font></font><font size="2">.WriteLine(</font><font color="#a31515" size="2"><font color="#a31515" size="2">&quot;Failed to execute <a href="http://test.py/" target="_blank">Test.py</a> file&quot;</font></font><font size="2">);</font><font size="2"> 
<p></p></font><font color="#0000ff" size="2"><font color="#0000ff" size="2">&nbsp;&nbsp;&nbsp; return</font></font><font size="2">; 
<p>}</p>
<p>&nbsp;</p>
<p>//call the function????</p>
<p>&nbsp;</p>
<p><font size="3">So how do I do the call to&nbsp;the function?</font></p>
<p><font size="3"></font>&nbsp;</p>
<p><font size="3">Thanks for your help.</font></p>
<p><font size="3">Bob</font></p>
<p><font size="3"></font>&nbsp;</p></font></div></div><br></div></div></div><br></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>