<div dir="ltr">A hosting API global is not the same as a Python global.&nbsp; After all, Python globals aren&#39;t really global; they&#39;re scoped to the module you&#39;re in.&nbsp; I can&#39;t provide sample code offhand, but to do what you want, you&#39;ll need to do something like the following steps:<br>
<br>1) Create an empty script scope<br>2) Set the &quot;name&quot; variable in that scope<br>3) Load your source into that already-created scope instead of creating a new one.<br><br>There are probably better ways to structure this code, but it looks like you&#39;re just working out a test program so I won&#39;t be pedantic about it.<br>
<br>In this sample code, you also haven&#39;t loaded System.Windows.Forms.dll; you can do that either through Python with clr.AddReference or from the hosting code with env.LoadAssembly.<br><br><div class="gmail_quote">On Sun, Aug 10, 2008 at 1:22 AM, Huzaifa <span dir="ltr">&lt;<a href="mailto:huzi_1982@hotmail.com">huzi_1982@hotmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
i am trying this code and it is giving me exception<br>
&quot;$exception &nbsp; &nbsp; {&quot;name &#39;name&#39; is not defined&quot;} &nbsp;System.Exception<br>
{System.Scripting.Runtime.UnboundNameException}<br>
&quot;<br>
CODE:<br>
<br>
ScriptRuntime env = ScriptRuntime.Create ( );<br>
ScriptScope defaultScope = env.CreateScope ( );<br>
ScriptEngine curEngine = env.GetEngine (&quot;py&quot;);<br>
ScriptSource input;<br>
<br>
env.LoadAssembly (typeof (System.Diagnostics.Debug).Assembly);<br>
env.Globals.SetVariable(&quot;name&quot;,&quot;Huzaifa&quot;);<br>
<br>
input = curEngine.CreateScriptSourceFromString (<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;@&quot;import clr<br>
from System import *<br>
from System.Windows.Forms import *<br>
<br>
MessageBox.Show(name)<br>
&quot;, SourceCodeKind.Statements);<br>
<br>
input.Execute (defaultScope);<br>
<font color="#888888"><br>
<br>
--<br>
View this message in context: <a href="http://www.nabble.com/System.Scripting.Runtime.UnboundNameException-tp18911599p18911599.html" target="_blank">http://www.nabble.com/System.Scripting.Runtime.UnboundNameException-tp18911599p18911599.html</a><br>

Sent from the IronPython mailing list archive at Nabble.com.<br>
<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>
</font></blockquote></div><br></div>