There are differences between modules that the console (ipy.exe) loads versus what is loaded when you compile.  When I build an exe I just go for the kill and reference everything.  msscorlib, System, and System.Data are key.<br>
<br>import sys<br>import clr<br><br>#Key IronPython References needed for final EXE when IronPython is not installed<br>clr.AddReference(&#39;IronPython&#39;)<br>clr.AddReference(&#39;IronPython.Modules&#39;)<br>clr.AddReference(&#39;Microsoft.Dynamic&#39;)<br>
clr.AddReference(&#39;Microsoft.Scripting&#39;)<br>clr.AddReference(&#39;Microsoft.Scripting.Core&#39;)<br>clr.AddReference(&#39;Microsoft.Scripting.Debugging&#39;)<br>clr.AddReference(&#39;Microsoft.Scripting.ExtensionAttribute&#39;)<br>
clr.AddReference(&#39;mscorlib&#39;)<br>clr.AddReference(&#39;System&#39;)<br>clr.AddReference(&#39;System.Data&#39;)<br><br>#References to .NET Assemblies used by this program<br>clr.AddReference(&quot;System.Xml.Linq&quot;)<br>
clr.AddReference(&quot;System.Xml&quot;)<br>clr.AddReference(&quot;System.Windows.Forms&quot;)<br>clr.AddReference(&quot;PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;)<br>clr.AddReference(&quot;PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot;)<br>
<br>#References to created DLL of python modules<br>clr.AddReference(&quot;StdLib&quot;)<br>clr.AddReference(&quot;ReportLab&quot;)<br><div class="gmail_quote"><br><br><br><br><br>On Tue, Feb 23, 2010 at 6:17 AM, Neidhoo Xaphier <span dir="ltr">&lt;<a href="mailto:xaphiern@googlemail.com">xaphiern@googlemail.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>Hello,<br><br>I have a very simple python script I want to compile into an exe-File (with IronPython 2.6). The script is named &quot;GuiTest.py&quot;:<br>
<br>### BEGIN GuiTest.py ###<br>import clr<br>clr.AddReference(&quot;PresentationFramework&quot;)<br>
clr.AddReference(&quot;PresentationCore&quot;)<br><br>import System.Windows<br>import System.Windows.Controls<br><br>window        = System.Windows.Window()<br>window.Title  = &quot;GuiTest&quot;<br>window.Height = 200<br>

window.Width  = 450<br><br>stack          = System.Windows.Controls.StackPanel()<br>stack.Margin   = System.Windows.Thickness(15)<br>window.Content = stack<br><br>button = System.Windows.Controls.Button() button.Content = &quot;Push Me!&quot;<br>

<br>def onClick(sender, event):<br>    print &quot;Button pushed!&quot;<br>    <br>button.Click += onClick<br><br>stack.Children.Add(button)<br><br>app = System.Windows.Application()<br>app.Run(window)<br>### END GuiTest.py ###<br>

<br>By using &quot;pyc.py&quot; I created &quot;GuiTest.exe&quot; with the following command line:<br><br>ipy &quot;C:\Programme\IronPython 2.6\Tools\Scripts\pyc.py&quot; /main:GuiTest.py /target:exe<br><br>Next I copied the following files into the same folder where GuiTest.exe is stored:<br>

<br>IronPython.dll<br>IronPython.Modules.dll<br>Microsoft.Scripting.ExtensionAttribute.dll<br>Microsoft.Dynamic.dll<br>Microsoft.Scripting.Core.dll<br>Microsoft.Scripting.Debugging.dll<br>Microsoft.Scripting.dll<br><br>Unfortunatelly GuiTest.exe still doesn&#39;t work. If I try to execute it from the command line I get the following error message:<br>

<br>Unbehandelte Ausnahme: System.InvalidOperationException: Beim aufrufenden Thread muss es sich um einen STA-Thread handeln, da dies für viele Komponenten der Benutzeroberfläche erforderlich ist.<br>   bei Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] args, Boolean&amp; shouldOptimize)<br>

   bei IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`6.Call5(Ca llSite site, CodeContext context, TFuncType func, T0 arg0, T1 arg1, T2 arg2, T3arg3, T4 arg4)<br>   bei System.Dynamic.UpdateDelegates.UpdateAndExecute7[T0,T1,T2,T3,T4,T5,T6,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)<br>

   bei IronPython.Runtime.Importer.Import(CodeContext context, String fullName, PythonTuple from, Int32 level)<br>   bei IronPython.Runtime.Operations.PythonOps.InitializeModule(Assembly precompiled, String main, String[] references)<br>

   bei PythonMain.Main()<br><br>Do you have any ideas how I can resolve this issue?<br><br>Best regards,<br>Xaphier N.<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>
<br></blockquote></div><br>