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('IronPython')<br>clr.AddReference('IronPython.Modules')<br>clr.AddReference('Microsoft.Dynamic')<br>
clr.AddReference('Microsoft.Scripting')<br>clr.AddReference('Microsoft.Scripting.Core')<br>clr.AddReference('Microsoft.Scripting.Debugging')<br>clr.AddReference('Microsoft.Scripting.ExtensionAttribute')<br>
clr.AddReference('mscorlib')<br>clr.AddReference('System')<br>clr.AddReference('System.Data')<br><br>#References to .NET Assemblies used by this program<br>clr.AddReference("System.Xml.Linq")<br>
clr.AddReference("System.Xml")<br>clr.AddReference("System.Windows.Forms")<br>clr.AddReference("PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")<br>clr.AddReference("PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")<br>
<br>#References to created DLL of python modules<br>clr.AddReference("StdLib")<br>clr.AddReference("ReportLab")<br><div class="gmail_quote"><br><br><br><br><br>On Tue, Feb 23, 2010 at 6:17 AM, Neidhoo Xaphier <span dir="ltr"><<a href="mailto:xaphiern@googlemail.com">xaphiern@googlemail.com</a>></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 "GuiTest.py":<br>
<br>### BEGIN GuiTest.py ###<br>import clr<br>clr.AddReference("PresentationFramework")<br>
clr.AddReference("PresentationCore")<br><br>import System.Windows<br>import System.Windows.Controls<br><br>window = System.Windows.Window()<br>window.Title = "GuiTest"<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 = "Push Me!"<br>
<br>def onClick(sender, event):<br> print "Button pushed!"<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 "pyc.py" I created "GuiTest.exe" with the following command line:<br><br>ipy "C:\Programme\IronPython 2.6\Tools\Scripts\pyc.py" /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> bei Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[] args, Boolean& 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>