Bug 41091 - The type initializer for 'System.Drawing.KnownColors' failed
Summary: The type initializer for 'System.Drawing.KnownColors' failed
Status: RESOLVED NOT_REPRODUCIBLE
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Drawing ()
Version: 4.2.0 (C6)
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-05-15 15:29 UTC by Mish Ochu
Modified: 2016-09-06 14:13 UTC (History)
3 users (show)

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

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 NOT_REPRODUCIBLE

Description Mish Ochu 2016-05-15 15:29:38 UTC
Sample code here: https://github.com/mishfit/QRCoder/tree/console-stdin

Given a file name 'foo' with content 'bar' (you'll have to create this file and pipe in the value (as shown below)
I'm receiving a type initializer exception

$ cat QRCoderConsole/bin/Debug/foo | mono QRCoderConsole/bin/Debug/QRCoderConsole.exe --out out.png
text retrieved from input stream: bar

System.TypeInitializationException
The type initializer for 'System.Drawing.KnownColors' threw an exception.
  at System.Drawing.Color.get_Black () <0x10cf971b0 + 0x0001e> in <filename unknown>:0 
  at QRCoder.QRCode.GetGraphic (Int32 pixelsPerModule) <0x10cf970f0 + 0x00023> in <filename unknown>:0 
  at QRCoderConsole.MainClass.GenerateQRCode (System.String payloadString, ECCLevel eccLevel, System.String outputFileName, System.Drawing.Imaging.ImageFormat imgFormat) <0x10cf71010 + 0x00122> in <filename unknown>:0 
  at QRCoderConsole.MainClass.Main (System.String[] args) <0x10a736e00 + 0x007f9> in <filename unknown>:0 
Try 'QRCoderConsole.exe --help' for more information


When running using Xamarin I do not get an error (but I can't pipe the file in either, instead I use '--in' parameter to reference the file).

I have two versions of mono running (brew and Xamarin):

$ /Library/Frameworks/Mono.framework/Versions/4.2.3/bin/mono --version
Mono JIT compiler version 4.2.3 (explicit/832de4b Thu Mar  3 19:24:57 EST 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  x86
	Disabled:      none
	Misc:          softdebug 
	LLVM:          yes(3.6.0svn-mono-(detached/a173357)
	GC:            sgen
$ mono --version
Mono JIT compiler version 4.2.3 (Stable 4.2.3.4/832de4b Wed Mar 30 13:57:48 PDT 2016)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
	TLS:           normal
	SIGSEGV:       altstack
	Notification:  kqueue
	Architecture:  amd64
	Disabled:      none
	Misc:          softdebug 
	LLVM:          supported, not enabled.
	GC:            sgen
Comment 1 Mish Ochu 2016-05-15 16:58:58 UTC
interestingly enough, this might be an issue with the brew version of mono

it runs just fine using "/Library/Frameworks/Mono.framework/Versions/4.2.3/bin/mono"
Comment 2 Alexander Köplinger [MSFT] 2016-09-06 14:13:03 UTC
I can't reproduce this with Mono JIT compiler version 4.6.0 (mono-4.6.0-branch/3ed2bba Mon Aug 29 20:00:29 EDT 2016), the out.png is generated fine.

Since you said it might be connected to the brew Mono version (which we don't have any control over) I'll be closing this issue. Thank you!