1

I have installed Mono (4.2.3) and libgdiplus (4.2) on my CentOS 7 and everything seems to be fine with the installation. mono-test-install returns:

Active Mono: /opt/mono/bin/mono
Your have a working System.Drawing setup
Your file system watcher is: System.IO.InotifyWatcher

Also compiled and launched console HelloWorld application without issues, but can't run any winforms app (including simplest HelloWorld example from Mono website). It gives me following messages when trying to run:

Unhandled Exception: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter] 
    at System.Drawing.GDIPlus.CheckStatus (Status status) <0x419aac90 + 0x0015f> in :0 
    at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelForm
    at format) <0x419fe280 + 0x00053> in :0 
    at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Int32 width, Int32 height) <0x41a004a0 + 0x0002f> in :0 
    at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Size newSize) <0x41a00460 + 0x0002b> in :0 
    at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (System.Drawing.Image,System.Drawing.Size) 
    at System.Windows.Forms.XplatUIX11.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) <0x419ffaf0 + 0x0020b> in :0 
    at System.Windows.Forms.XplatUI.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) <0x419ffa70 + 0x00070> in :0 
    at System.Windows.Forms.Cursor.CreateCursor (System.IO.Stream stream) <0x419fc0e0 + 0x00193> in :0 
    at System.Windows.Forms.Cursor..ctor (System.Type type, System.String resource) <0x419fbea0 + 0x0006b> in :0 
    at System.Windows.Forms.Cursors.get_SizeNWSE () <0x419fbd40 + 0x0005b> in :0 
    at System.Windows.Forms.SizeGrip..ctor (System.Windows.Forms.Control CapturedControl) <0x419fbcb0 + 0x0001f> in :0 
    at (wrapper remoting-invoke-with-check) System.Windows.Forms.SizeGrip:.ctor (System.Windows.Forms.Control) 
    at System.Windows.Forms.ScrollableControl.CreateScrollbars () <0x419f8e40 + 0x004ff> in :0 
    at System.Windows.Forms.ScrollableControl..ctor () <0x419a5e30 + 0x00387> in :0 
    at System.Windows.Forms.ContainerControl..ctor () <0x419a5ca0 + 0x00027> in :0 
    at System.Windows.Forms.Form..ctor () <0x419a5420 + 0x000bb> in :0 
    at HelloWorld..ctor () <0x419a2fa0 + 0x0000f> in :0 
    at (wrapper remoting-invoke-with-check) HelloWorld:.ctor () 
    at HelloWorld.Main () <0x419a2d90 + 0x0001f> in :0 

Tried also run with MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono test.exe

and it finds all the libraries needed. Found few similar messages in the Internet but no solutions anywhere. Tried hard to use my brain and still nothing. A while ago I have installed the same version of Mono in the same system but other machine and it worked just fine. This message shows up no matter if I install via yum or compiling from sources.

flaviut
  • 2,007
  • 3
  • 23
  • 32
goodfellow
  • 3,525
  • 1
  • 17
  • 19
  • 1
    It seems that you installed mono on your own, compiling from sources (because of the /opt prefix), this is most of the time wrong, you only want to install in this prefix when you're installing a second parallel version of mono (besides the supplied one from your distro). On top of that, I have the experience that distros of the RedHat family (Fedora, CentOS) work in a very unstable way with mono. I recommend you to try Ubuntu16.04 first with the distro provided packages, to first rule out the possibility that your problem comes from the fact that you chose this distribution. – user1623521 Jun 06 '16 at 13:27
  • Possible duplicate of [Running simple winforms application on Mono for ARM](https://stackoverflow.com/questions/28674759/running-simple-winforms-application-on-mono-for-arm) – flaviut Feb 18 '19 at 20:26

1 Answers1

0

This seems like a problem with the System.Drawing DLL, similar to another answer I wrote.

First, locate the directory where is the System.Drawing.dll file (for example /opt/mono-4.4.0/lib/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll)

Create a file in the same directory called System.Drawing.dll.config with the following content, updating the directory to the correct location of libgdiplus.so:

<configuration>
  <dllmap dll="gdiplus.dll" target="/opt/mono-4.4.0/lib/libgdiplus.so"/>
</configuration>
Community
  • 1
  • 1
dougstefe
  • 26
  • 3
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you earn sufficient reputation you will be able to comment on any post. If you have a related but different question, ask a new question referencing this one if it will help provide context. – Rohan Khude Aug 23 '16 at 16:55