[IronPython] Can't start executable created with pyc.py

Dino Viehland dinov at microsoft.com
Tue Feb 23 18:11:40 CET 2010

I think you need to compile with /target:winexe so the app will start on a sta thread.

Sent from my Android phone using TouchDown (www.nitrodesk.com)

-----Original Message-----
From: Neidhoo Xaphier [xaphiern at googlemail.com]
Received: 2/23/10 4:17 AM
To: users at lists.ironpython.com [users at lists.ironpython.com]
Subject: [IronPython] Can't start executable created with pyc.py


I have a very simple python script I want to compile into an exe-File (with IronPython 2.6). The script is named "GuiTest.py":

### BEGIN GuiTest.py ###
import clr

import System.Windows
import System.Windows.Controls

window        = System.Windows.Window()
window.Title  = "GuiTest"
window.Height = 200
window.Width  = 450

stack          = System.Windows.Controls.StackPanel()
stack.Margin   = System.Windows.Thickness(15)
window.Content = stack

button = System.Windows.Controls.Button() button.Content = "Push Me!"

def onClick(sender, event):
    print "Button pushed!"

button.Click += onClick


app = System.Windows.Application()
### END GuiTest.py ###

By using "pyc.py" I created "GuiTest.exe" with the following command line:

ipy "C:\Programme\IronPython 2.6\Tools\Scripts\pyc.py" /main:GuiTest.py /target:exe

Next I copied the following files into the same folder where GuiTest.exe is stored:


Unfortunatelly GuiTest.exe still doesn't work. If I try to execute it from the command line I get the following error message:

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.
   bei Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] args, Boolean& shouldOptimize)
   bei IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`6.Call5(Ca llSite site, CodeContext context, TFuncType func, T0 arg0, T1 arg1, T2 arg2, T3arg3, T4 arg4)
   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)
   bei IronPython.Runtime.Importer.Import(CodeContext context, String fullName, PythonTuple from, Int32 level)
   bei IronPython.Runtime.Operations.PythonOps.InitializeModule(Assembly precompiled, String main, String[] references)
   bei PythonMain.Main()

Do you have any ideas how I can resolve this issue?

Best regards,
Xaphier N.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100223/65810631/attachment.html>

More information about the Ironpython-users mailing list