Hmmm, do you have Visual Studio installed so that you could possibly debug
the application when it fails at the end and pinpoint the spot of failure?

Thanks,

slide

2012/3/19 <sepa...@sibmail.com>

> Hello).
> With the advice Matt Ward, thanks to him, the problem was solved as
> follows:
> 1) had to change avalon.py as follows:
> commented out 2 lines
> .............
> t = Thread(ThreadStart(start))
> t.IsBackground = True
> t.ApartmentState = ApartmentState.STA
> #t.Start()
> #are.WaitOne()
> ..............
>
> 2) changed the file primer.py:
> from avalon import *
> import calculator
> global app
> global dispatcher
> app = Application()
> app.Startup += on_startup
> w = Window()
> w.Title = "My Avalon Application"
> w.Content = LoadXaml("calc.xaml")
> calculator.enliven(w)
> app.Run(w)
> w.Show()
>
> 3) after compilation:
> c:\IronPython\ipy.exe pyc.py /main: primer.py /target: winexe /platform:
> x86 /standalone
> was working primer.exe
> but ...
> not without nuance):
> after closing the window appears the system error message:
> primer.exe - an error is detected. The application will be closed. We are
> We apologize for any inconvenience.
> If the work was not finished, operational data may be lost.
> This message did not have to be.
> Maybe there is someone the idea.)
>
> Thank you.
>
> > You will need to keep the message pump alive by using Application.Run.
> > The following code should work (new first line and last two lines):
> >
> > from System.Windows import Application
> >
> > from avalon import *
> > import calculator
> > w = Window()
> > w.Title = "My Avalon Application"
> > w.Content = LoadXaml("calc.xaml")
> > calculator.enliven(w)
> >
> > app = Application()
> > app.Run(w)
> >
> > On 19 March 2012 09:29,  <sepa...@sibmail.com> wrote:
> >> Thank you, Matt Ward :).
> >> В It worked :)). You're a real expert.
> >> В Just one more thing, a window appears and then disappears. I guess,
> >> because the console is closed.
> >> В Maybe after the text of the program in primer.py something else should
> >> be?
> >>
> >> from avalon import *
> >> import calculator
> >> w = Window()
> >> w.Title = "My Avalon Application"
> >> w.Content = LoadXaml("calc.xaml")
> >> calculator.enliven(w)
> >> w.Show()
> >> ??????????????????????????????????
> >>
> >>> If you use the /target:winexe with pyc.py it will add the STAThread
> >>> attribute to your main method. That should fix the exception.
> >>>
> >>> In the C# console app you can add the STAThread attribute to the main
> >>> method:
> >>>
> >>>       class Program
> >>>       {
> >>>             [STAThread]
> >>>             static void Main(string[] args)
> >>>             {
> >>>
> >>> On 19 March 2012 08:17, В <sepa...@sibmail.com> wrote:
> >>>> I have a need to run a WPF application written in IronPython on the
> >>>> client
> >>>> without installing IronPython.
> >>>> Technology to try to debug a standard example of WPF
> >>>> .\IronPython-2.7.2.1\Tutorial.
> >>>> Baseline data:
> >>>>
> >>>> 1) The computer is not installed IronPython. From
> >>>> IronPython-2.7.2.1.zip
> >>>> (download program) extracted in C:\IronPython
> >>>>
> >>>> 2) Create a C:\IronPython subdirectory pyc_d.
> >>>>
> >>>> 3) In the C:\IronPython\pyc_d created a file primer.py:
> >>>>
> >>>> from avalon import *
> >>>> import calculator
> >>>> w = Window()
> >>>> w.Title = "My Avalon Application"
> >>>> w.Content = LoadXaml("calc.xaml")
> >>>> calculator.enliven(w)
> >>>> w.Show()
> >>>>
> >>>> 4)pyc_d contains:
> >>>>
> >>>> IronPython.dll
> >>>> IronPython.Modules.dll
> >>>> IronPython.Wpf.dll
> >>>> Microsoft.Scripting.dll
> >>>>
> >>>> avalon.py
> >>>> Calc.xaml
> >>>> calculator.py
> >>>> primer.py
> >>>> pyc.py
> >>>>
> >>>> 5) Run ipy.exe, sequentially enter commands from the primer.py, it
> >>>> works
> >>>> :).
> >>>>
> >>>> 6) Next:
> >>>> c:\IronPython\ipy.exe pyc.py /main:primer.py /target:exe
> /platform:x86 /standalone
> >>>> I get primer.exe (4,09 MB).
> >>>>
> >>>> 7) Run from the console, I get:
> >>>> C:\IronPython\pyc_d>primer.exe
> >>>>
> >>>> An unhandled exception: System.InvalidOperationException: The calling
> >>>> thread must be STA, because many UI components require this.
> >>>>
> >>>> Microsoft.Scripting.Interpreter.NewInstruction.Run(InterpretedFrame
> >>>> frame)
> >>>>
> >>>> Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame
> >>>> frame)
> >>>>
> >>>> Microsoft.Scripting.Interpreter.LightLambda.Run3[T0,T1,T2,TRet](T0
> >>>> arg0, T1 arg1, T2 arg2)
> >>>>
>  
> ...............................................................................
> >>>> All is not enumerate
> >>>>
> >>>> It seems to do everything correctly. I take an example from the
> >>>> Tutorial,
> >>>> the files from the Tutorial, to be going smoothly, but ... What is the
> >>>> problem?
> >>>>
> >>>> 8)Try another option. Make a thin client in C #.
> >>>> Create a console C # project, and Program.cs:
> >>>>
> >>>> using System;
> >>>> using IronPython.Hosting;
> >>>> using Microsoft.Scripting.Hosting;
> >>>> using System.Reflection;
> >>>> using System.IO;
> >>>>
> >>>> namespace ConsoleApplication1
> >>>> {
> >>>>          class Program
> >>>>          {
> >>>>                    static void Main(string[] args)
> >>>>                    {
> >>>>                            string path =
> Assembly.GetExecutingAssembly().Location;
> >>>>                            string dir =
> Directory.GetParent(path).FullName;
> >>>>
> >>>>                              ScriptEngine engine =
> Python.CreateEngine();
> >>>>                              ScriptSource source =
> engine.CreateScriptSourceFromFile(Path.Combine(dir,
> args[0]));
> >>>>                              CompiledCode compiled = source.Compile();
> >>>>                              ScriptScope scope = engine.CreateScope();
> >>>>                              compiled.Execute(scope);
> >>>>                    }
> >>>>          }
> >>>> }
> >>>>
> >>>> 9) run:
> >>>> C:\IronPython\pyc_d>ConsoleApplication1.exe primer.py
> >>>>
> >>>> the same result: (Unhandled exception:
> >>>> System.InvalidOperationException:
> >>>> The calling thread must be STA, because many UI components require
> >>>> this.)
> >>>> What is the problem?
> >>>> Are there any experts who can create learning (from Tutorial) WPF
> >>>> application and run it on a machine without installing IronPython from
> >>>> the console?
> >>>> Thank you.)
> >>>>
> >>>> _______________________________________________
> >>>> Ironpython-users mailing list
> >>>> Ironpython-users@python.org
> >>>> http://mail.python.org/mailman/listinfo/ironpython-users
> >>>
> >>
> >>
> >
>
>
> _______________________________________________
> Ironpython-users mailing list
> Ironpython-users@python.org
> http://mail.python.org/mailman/listinfo/ironpython-users
>



-- 
Website: http://earl-of-code.com
_______________________________________________
Ironpython-users mailing list
Ironpython-users@python.org
http://mail.python.org/mailman/listinfo/ironpython-users

Reply via email to