On 09.09.2011 13:06, Doug Blank wrote: > On Fri, Sep 9, 2011 at 3:34 AM, Elmar Haneke<el...@haneke.de> wrote: >> >> >> Am 08.09.2011 20:06, schrieb Doug Blank: >> >>> Wow... nothing. No activity in the bug tracker. No response here. >>> Maybe someone can make some guesses about the issue, or why I can't >>> get any comments: >> >> Perhaps you can find an solution in >> https://bugzilla.novell.com/show_bug.cgi?id=380675 > > Yes! Thank you, thank you, thank you! > > It turns out that if you want to use Gtk.PrintOperation, your Main > function, wherever it is, must have the [STAThread] attribute. > > I've been using Mono and Gtk# for a year now without this (just using > Gtk.Application.Invoke for to run in the correct thread), but Printing > appears to require STAThread. (My application is actually written in
The printing support is invoking native Windows functions, and some of them need a STA thread. > IronPython, which would be problematic as there is no way to set this > attribute, and so there appears to be no way to have a pure IronPython > app that prints in Windows. But this is easily remedied by creating a > little C# wrapper). You don't need a wrapper if you translate this to IronPython: // entry point static void Main (string[] args) { // create a STA thread Thread t = new Thread(delegate { RealMain(args); }); t.SetApartmentState(ApartmentState.STA); t.Start(); t.Join(); } static void RealMain(string[] args) { // do stuff you've done in main before } Robert _______________________________________________ Mono-list maillist - Mono-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-list