configurator
configurator

Reputation: 41690

Running mono on Windows with Winforms applications exits immediately

I've got mono 3.2.3 installed. When I try to run a Winforms application - even one as simple as the default template when creating a new project - mono exits immediately with exit code 1 without doing anything, and with no output. Console Applications work fine.

This is from trying to run it in Cygwin:

Screenshot of the issue

Upvotes: 0

Views: 379

Answers (1)

configurator
configurator

Reputation: 41690

By changing the project's Output Type to Console Application I got error messages in the console.

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeWin32Classic ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.KnownColors ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so

Googling that lead me to a page in mono's bug tracker: https://bugzilla.xamarin.com/show_bug.cgi?id=8309

Apparently, this bug was already fixed a year ago, but only merged into mono 3.4.0. The workaround is to edit the file

$MONO/etc/mono/config

and remove the two offending lines:

<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" />

This fixed the issue.

Upvotes: 1

Related Questions