Bug 218 - Gtk print demo fails on Windows7 for all versions of Mono/Gtk
Summary: Gtk print demo fails on Windows7 for all versions of Mono/Gtk
Status: RESOLVED INVALID
Alias: None
Product: Gtk#
Classification: Mono
Component: gtk-sharp ()
Version: 2.x
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-08-07 12:20 UTC by Doug Blank
Modified: 2011-09-09 07:23 UTC (History)
1 user (show)

Tags: gtk print
Is this bug a regression?: ---
Last known good build:


Attachments
Stand-alone c# DemoPrinting.cs; gmcs DemoPrinting.cs /pkg:gtk-sharp-2.0 -r:Mono.Cairo (3.58 KB, text/plain)
2011-08-07 12:20 UTC, Doug Blank
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Doug Blank 2011-08-07 12:20:31 UTC
Created attachment 80 [details]
Stand-alone c# DemoPrinting.cs; gmcs DemoPrinting.cs /pkg:gtk-sharp-2.0 -r:Mono.Cairo

I am trying the GtkDemo on Windows7, and it just hangs.

I have created a stand-alone version of DemoPrinting.cs and is attached.
Comment 1 Doug Blank 2011-08-07 12:22:29 UTC
Works on Linux with Mono 2.6.7. 

Compile with:

gmcs DemoPrinting.cs /pkg:gtk-sharp-2.0 -r:Mono.Cairo

Run with:

mono DemoPrinting.exe

Is there a work-around for printing cross-platform, including Windows7?
Comment 2 Doug Blank 2011-08-07 18:24:21 UTC
DemoPrinting.exe works on Mac OS X running Mono 2.6.7, too, BTW. This appears to only be a Windows7 issue.
Comment 3 Doug Blank 2011-09-09 07:23:31 UTC
Thanks to Elmar Haneke on the mono-list for providing a hint by pointing to https://bugzilla.novell.com/show_bug.cgi?id=380675

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
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).

BTW, this attribute is only needed on Windows: Linux and Mac worked fine without it.