<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
 <span style="font-family:Arial,Helvetica,sans-serif; font-size:small">I think you need to compile with /target:winexe so the app will start on a sta thread.<br>
<br>
Sent from my Android phone using TouchDown (www.nitrodesk.com)</span><br>
<br>
-----Original Message----- <br>
<b>From:</b> Neidhoo Xaphier [xaphiern@googlemail.com]<br>
<b>Received:</b> 2/23/10 4:17 AM<br>
<b>To:</b> users@lists.ironpython.com [users@lists.ironpython.com]<br>
<b>Subject:</b> [IronPython] Can't start executable created with pyc.py<br>
<br>
<div>&nbsp;<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&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = System.Windows.Window()<br>
window.Title&nbsp; = &quot;GuiTest&quot;<br>
window.Height = 200<br>
window.Width&nbsp; = 450<br>
<br>
stack&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = System.Windows.Controls.StackPanel()<br>
stack.Margin&nbsp;&nbsp; = 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>
&nbsp;&nbsp;&nbsp; print &quot;Button pushed!&quot;<br>
&nbsp;&nbsp;&nbsp; <br>
button.Click &#43;= 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'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>
&nbsp;&nbsp; bei Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] args, Boolean&amp; shouldOptimize)<br>
&nbsp;&nbsp; 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>
&nbsp;&nbsp; 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>
&nbsp;&nbsp; bei IronPython.Runtime.Importer.Import(CodeContext context, String fullName, PythonTuple from, Int32 level)<br>
&nbsp;&nbsp; bei IronPython.Runtime.Operations.PythonOps.InitializeModule(Assembly precompiled, String main, String[] references)<br>
&nbsp;&nbsp; bei PythonMain.Main()<br>
<br>
Do you have any ideas how I can resolve this issue?<br>
<br>
Best regards,<br>
Xaphier N.<br>
</div>
</body>
</html>