Page 1 of 1

TypeInitializationException error

Posted: Wed Feb 26, 2014 9:50 pm
by Rydrael
Hello,

I'm having some issues when executing the game OpenRA from the latest changes in HEAD of the project. About 2 months ago or so I could execute and play the game from the Git without any problem, yet know I run into a TypeInitializationException error. Here is the Stack Trace:

System.TypeInitializationException: An exception was thrown by the type initializer for OpenRA.Support.PerfHistory ---> System.Exception: An exception was thrown by the type initializer for System.Drawing.KnownColors ---> System.Exception: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.Exception: /opt/mono-3/lib/libgdiplus.so
at at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000cc] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:127
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x0001a] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/KnownColors.cs:225
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Red () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/Color.cs:907
at OpenRA.Support.PerfHistory..cctor () [0x00000] in /home/rydra/projects/OpenRA/OpenRA.Game/Support/PerfHistory.cs:20
--- End of inner exception stack trace ---
at OpenRA.Game.Initialize (OpenRA.Arguments args) [0x002d0] in /home/rydra/projects/OpenRA/OpenRA.Game/Game.cs:321
at OpenRA.Program.Run (System.String[] args) [0x00007] in /home/rydra/projects/OpenRA/OpenRA.Game/Support/Program.cs:112
at OpenRA.Program.Main (System.String[] args) [0x00027] in /home/rydra/projects/OpenRA/OpenRA.Game/Support/Program.cs:30


I'm trying to run it on Ubuntu Linux 13.10 and I use Monodevelop 4.2 as my IDE with Mono 3 (previously I used Monodevelop 3 but latest changes in Git didn't allow me to open the *.sln file with it, only with version 4).

Any ideas about how to solve this? Thank you!

Posted: Wed Feb 26, 2014 11:34 pm
by Sleipnir
This looks to be a problem with your mono installation. Are you using the default packages from ubuntu, a ppa, or a custom build?

Posted: Fri Feb 28, 2014 8:58 am
by Rydrael
Sleipnir wrote: This looks to be a problem with your mono installation. Are you using the default packages from ubuntu, a ppa, or a custom build?
I installed monodevelop 4 from this PPA: https://launchpad.net/~keks9n/+archive/ ... lop-latest . Latest source code from git didn't allow me to open the sln file in monodevelop 3, so I had to install monodevelop 4 which, at the same time, installs mono 3.

Posted: Fri Feb 28, 2014 4:46 pm
by Matt
It works fine here on openSUSE with Mono 3.2.3 using MonoDevelop 4.2.1 so I don't think that is the problem if those PPAs did everything correctly. You can try to give is the version of libgdiplus and the output of mono --version. Also be sure to run make dependencies before running the game when https://github.com/OpenRA/OpenRA/wiki/Compiling from source.

Posted: Sat Mar 01, 2014 1:46 pm
by Rydrael
Cmd. Matt wrote: It works fine here on openSUSE with Mono 3.2.3 using MonoDevelop 4.2.1 so I don't think that is the problem if those PPAs did everything correctly. You can try to give is the version of libgdiplus and the output of mono --version. Also be sure to run make dependencies before running the game when https://github.com/OpenRA/OpenRA/wiki/Compiling from source.
Ok, I solved it. From monodevelop 4 I could run the game successfully by going to Run->Run With->mono 2.10.8.1 instead of mono 3.2.3.

This is the exception that it throws when trying to run it with mono 3.2.3, which I think provides more details than my first post:

Platform is Linux
Using SDL 1.2 with OpenGL renderer
Desktop resolution: 1366x768
No custom resolution provided, using desktop resolution
Using resolution: 1366x768
Using OpenAL sound engine
Using default device
Available mods:
cnc: Tiberian Dawn ({DEV_VERSION})
d2k: Dune 2000 ({DEV_VERSION})
ra: Red Alert ({DEV_VERSION})
ts: Tiberian Sun ({DEV_VERSION})
Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for OpenRA.Support.PerfHistory
Inner Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for System.Drawing.KnownColors
Inner Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for System.Drawing.GDIPlus
Inner Exception of type `System.DllNotFoundException`: /opt/mono-3/lib/libgdiplus.so
TypeName=``
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000cc] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:127
at System.Drawing.KnownColors..cctor () [0x0001a] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/KnownColors.cs:225
at System.Drawing.Color.get_Red () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/Color.cs:907
at OpenRA.Support.PerfHistory..cctor () [0x00000] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/PerfHistory.cs:20
at OpenRA.Game.Initialize (OpenRA.Arguments args) [0x002d0] in /home/rydrael/projects/OpenRA/OpenRA.Game/Game.cs:321
at OpenRA.Program.Run (System.String[] args) [0x00007] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/Program.cs:112
at OpenRA.Program.Main (System.String[] args) [0x0005a] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/Program.cs:38
Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext
Inner Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine
Inner Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for System.Windows.Forms.ThemeWin32Classic
Inner Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for System.Drawing.KnownColors
Inner Exception of type `System.TypeInitializationException`: An exception was thrown by the type initializer for System.Drawing.GDIPlus
Inner Exception of type `System.DllNotFoundException`: /opt/mono-3/lib/libgdiplus.so
TypeName=``
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000cc] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:127
at System.Drawing.KnownColors..cctor () [0x0001a] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/KnownColors.cs:225
at System.Drawing.Color.get_Red () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/Color.cs:907
at OpenRA.Support.PerfHistory..cctor () [0x00000] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/PerfHistory.cs:20
at System.Windows.Forms.ThemeEngine..cctor () [0x0003c] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeEngine.cs:51
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SystemInformation.cs:317
at System.Windows.Forms.Control..ctor () [0x000e3] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:900
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WindowsFormsSynchronizationContext.cs:45
at System.Windows.Forms.Control..ctor () [0x00014] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:871
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs:157
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs:54
at System.Windows.Forms.Form..ctor () [0x00012] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs:387
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:.ctor ()
at OpenRA.FatalErrorDialog.Show () [0x00007] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/FatalErrorDialog.cs:23
at OpenRA.Program.FatalError (System.Exception e) [0x00102] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/Program.cs:65
at OpenRA.Program.Main (System.String[] args) [0x00068] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/Program.cs:42
[ERROR] FATAL 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: /opt/mono-3/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000cc] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs:127
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x0001a] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/KnownColors.cs:225
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Red () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/System.Drawing/System.Drawing/Color.cs:907
at OpenRA.Support.PerfHistory..cctor () [0x00000] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/PerfHistory.cs:20
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x0003c] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeEngine.cs:51
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/SystemInformation.cs:317
at System.Windows.Forms.Control..ctor () [0x000e3] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:900
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/WindowsFormsSynchronizationContext.cs:45
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00014] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs:871
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ScrollableControl.cs:157
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ContainerControl.cs:54
at System.Windows.Forms.Form..ctor () [0x00012] in /build/buildd/mono-3-opt-3.2.3/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs:387
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Form:.ctor ()
at OpenRA.FatalErrorDialog.Show () [0x00007] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/FatalErrorDialog.cs:23
at OpenRA.Program.FatalError (System.Exception e) [0x00102] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/Program.cs:65
at OpenRA.Program.Main (System.String[] args) [0x00068] in /home/rydrael/projects/OpenRA/OpenRA.Game/Support/Program.cs:42

I noticed the "Inner Exception of type `System.DllNotFoundException`: /opt/mono-3/lib/libgdiplus.so", and indeed that file was not in there.

So, I did the following:

sudo ln -s /usr/lib/libgdiplus.so /opt/mono-3/lib/libgdiplus.so

and voilà! The game now runs with mono 3.2.3. I wonder why that file wasn't there.

Thanks for the tips!