ljs.dev
ljs.dev

Reputation: 4483

System.Drawing mono failure debugging

As per this answer regarding failed mono-test-install results, I put the following in test.cs:

using System;
using System.Drawing;

class X { 
    static void Main ()
    {
        Bitmap b = new Bitmap (100, 100);
    }
}

Then ran

mcs -pkg:dotnet test.cs

output:

test.cs(7,16): warning CS0219: The variable `b' is assigned but its value is never used Compilation succeeded - 1 warning(s)

And ran the resulting exe with:

mono test.exe

output:

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (int,int)
  at X.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
  at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
  at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0 
  at System.Drawing.Bitmap..ctor (Int32 width, Int32 height) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (int,int)
  at X.Main () [0x00000] in <filename unknown>:0 

Is it safe to ignore this or should I be debugging the line NotFoundException: /usr/local/lib/libgdiplus.so next?

Upvotes: 1

Views: 2789

Answers (1)

ljs.dev
ljs.dev

Reputation: 4483

Thanks Jon, I'd just found that page and though I didn't follow it verbatim, I put a symlink in as:

sudo ln -s /usr/lib/libgdiplus.so /usr/local/lib/libgdiplus.so

Which resolved the errors and now mono-test-install returns:

Your have a working System.Drawing setup

Besides the grammatical issues, it should be resolved.

Upvotes: 3

Related Questions