Bug 27160 - System.Drawing.Graphics.DrawLine will throw exception every time on Yosemite
Summary: System.Drawing.Graphics.DrawLine will throw exception every time on Yosemite
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Drawing ()
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-02-17 16:22 UTC by Jon
Modified: 2015-09-21 12:26 UTC (History)
5 users (show)

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


Attachments
Solution to reproduce GDI exception. (6.98 MB, application/zip)
2015-02-17 16:22 UTC, Jon
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 for Bug 27160 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Jon 2015-02-17 16:22:57 UTC
Created attachment 9888 [details]
Solution to reproduce GDI exception.

Sample code from our PrintDocument.PrintPage event handler:

		void HandlePrintPage (object sender, PrintPageEventArgs e)
		{
			var g = e.Graphics;
			g.DrawLine (new System.Drawing.Pen (System.Drawing.Brushes.Black), 0, 0, 300, 0);
		}

This will predictably throw the following exception on Yosemite:

System.Exception: Generic Error [GDI+ status: GenericError]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x0007a] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:217 
  at System.Drawing.Graphics.DrawLine (System.Drawing.Pen pen, Single x1, Single y1, Single x2, Single y2) [0x00057] in /private/tmp/source-mono-mac-3.12.0-branch-32/bockbuild-mono-3.12.0-branch/profiles/mono-mac-xamarin/build-root/mono-3.12.0/mcs/class/System.Drawing/System.Drawing/Graphics.cs:1035 
  at (wrapper remoting-invoke-with-check) System.Drawing.Graphics:DrawLine (System.Drawing.Pen,single,single,single,single)


Please note that this exception does NOT occur on Mavericks, so something in Yosemite clearly broke the framework. Attached is a sample project that will reproduce the exception. It is coded against our receipt printer (Star Micronics TSP100), so you will likely have to tweak.

This is an active production issue that is currently affecting our Mac client base who have upgraded to Yosemite.
Comment 1 Chris Hamons 2015-02-17 17:30:32 UTC
System.Drawing is not Xamarin.Mac. I've moved this to the mono class libraries section.
Comment 2 Chris Hamons 2015-02-17 17:33:15 UTC
What version of mono are you using? Are you using one that you got from Xamarin Studio? An old version of mono was mispackaged and causing issue.

See: http://forums.xamarin.com/discussion/27011/fix-for-gdipcreatefromcontext-macosx-and-other-macios-gdi-issues?new=1
Comment 3 Chris Hamons 2015-02-17 17:34:02 UTC
However, since it only happens on Yosemite, unless only that machine has the "bad" mono, it is probably an implementation issue.
Comment 4 Jon 2015-02-17 17:37:16 UTC
I've attempted with Mono 3.10 and 3.12 that came with Xamarin, and also attempted using 3.10.0.31 which Cody provided me earlier. All of them produced the same exception.
Comment 5 Jon 2015-03-04 13:21:41 UTC
Currently using GTK# as a workaround for printing, and that seems to be doing the job for the time being.