Kishor
Kishor

Reputation: 23

Unhandled Exception while running .exe on mono framework in Ubuntu 13.04

I am using ubuntu 13.04, I installed mono-3.1.2 on Ubuntu-13.04 successfully. Now i am trying to run C# .exe from windows visual studio.

     $ mono WindowsFormsApplication1.exe

I am getting the following :-

                   Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> 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.Graphics.FromHdcInternal (IntPtr hdc) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.GetInstance () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUI..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () [0x00000] in <filename unknown>:0 
  at WindowsFormsApplication1.Program.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> 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.Graphics.FromHdcInternal (IntPtr hdc) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUIX11.GetInstance () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.XplatUI..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Application.EnableVisualStyles () [0x00000] in <filename unknown>:0 
  at WindowsFormsApplication1.Program.Main () [0x00000] in <filename unknown>:0

How to remove this exception , please help me. Thanks in advance.

Upvotes: 1

Views: 5601

Answers (3)

robertspierre
robertspierre

Reputation: 4361

I fixed the problem on Fedora 23 by installing libgdiplus-devel as follows:

dnf install libgdiplus-devel

Upvotes: 0

Lex Li
Lex Li

Reputation: 63173

As @knocte pointed out, you should

  • Install Mono via apt-get such as sudo apt-get install mono-complete, so that libgdiplus is installed as well,
  • Or compile both libgdiplus and Mono from source code.

Upvotes: 1

kronenpj
kronenpj

Reputation: 221

raffamaiden's answer worked for me, but there's a small spelling mistake in the answer:

dnf install libgdiplus-devel

Upvotes: 0

Related Questions