在Ubuntu 13.04的mono framework上运行.exe时出现未处理的异常

在Ubuntu 13.04的mono framework上运行.exe时出现未处理的异常,mono,Mono,我使用的是ubuntu 13.04,我在ubuntu-13.04上成功安装了mono-3.1.2。 现在我正在尝试从windows visual studio运行C#.exe $ mono WindowsFormsApplication1.exe 我得到以下信息:- Unhandled Exception: System.TypeInitializationException: An exception was thrown by the typ

我使用的是ubuntu 13.04,我在ubuntu-13.04上成功安装了mono-3.1.2。 现在我正在尝试从windows visual studio运行C#.exe

     $ mono WindowsFormsApplication1.exe
我得到以下信息:-

                   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
未处理的异常:
System.TypeInitializationException:System.Windows.Forms.XplatUI的类型初始值设定项-->System.TypeInitializationException:System.Drawing.GDIPlus的类型初始值设定项-->System.DllNotFoundException:/usr/local/lib/libgdiplus.so的类型初始值设定项引发异常
在(包装器管理为本机)System.Drawing.GDIPlus:GdiplusStartup(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
位于System.Drawing.GDIPlus..cctor()[0x00000]中:0
---内部异常堆栈跟踪的结束---
在System.Drawing.Graphics.FromHDC内部(IntPtr hdc)[0x00000]中:0
在System.Windows.Forms.XplatUIX11.SetDisplay(IntPtr display_handle)[0x00000]中:0
在System.Windows.Forms.XplatUIX11..ctor()[0x00000]中:0
位于:0中的System.Windows.Forms.XplatUIX11.GetInstance()[0x00000]处
在System.Windows.Forms.XplatUI..cctor()[0x00000]中:0
---内部异常堆栈跟踪的结束---
位于:0中的System.Windows.Forms.Application.EnableVisualStyles()[0x00000]
在0中的WindowsFormsApplication1.Program.Main()[0x00000]处
[错误]致命的未处理异常:System.TypeInitializationException:System.Windows.Forms.XplatUI-->System.TypeInitializationException的类型初始值设定项引发了异常:System.Drawing.GDIPlus-->System.DllNotFoundException:/usr/local/lib/libgdiplus.so的类型初始值设定项引发了异常
在(包装器管理为本机)System.Drawing.GDIPlus:GdiplusStartup(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
位于System.Drawing.GDIPlus..cctor()[0x00000]中:0
---内部异常堆栈跟踪的结束---
在System.Drawing.Graphics.FromHDC内部(IntPtr hdc)[0x00000]中:0
在System.Windows.Forms.XplatUIX11.SetDisplay(IntPtr display_handle)[0x00000]中:0
在System.Windows.Forms.XplatUIX11..ctor()[0x00000]中:0
位于:0中的System.Windows.Forms.XplatUIX11.GetInstance()[0x00000]处
在System.Windows.Forms.XplatUI..cctor()[0x00000]中:0
---内部异常堆栈跟踪的结束---
位于:0中的System.Windows.Forms.Application.EnableVisualStyles()[0x00000]
在0中的WindowsFormsApplication1.Program.Main()[0x00000]处
如何删除此异常,请帮助我。
提前谢谢。

正如@knocte所指出的,你应该

  • 通过apt get安装Mono,例如
    sudo apt get Install Mono complete
    ,以便同时安装libgdiplus
  • 或者从源代码编译libgdiplus和Mono

    • 正如@knocte所指出的,你应该

      • 通过apt get安装Mono,例如
        sudo apt get Install Mono complete
        ,以便同时安装libgdiplus
      • 或者从源代码编译libgdiplus和Mono

      我通过安装
      libgdiplus-devel
      修复了Fedora 23上的问题,如下所示:

      dnf install libgdiplus-devel
      

      我通过安装
      libgdiplus-devel
      修复了Fedora 23上的问题,如下所示:

      dnf install libgdiplus-devel
      

      拉法迈登的答案对我来说很有用,但答案中有一个小的拼写错误:

      dnf install libgdiplus-devel
      

      拉法迈登的答案对我来说很有用,但答案中有一个小的拼写错误:

      dnf install libgdiplus-devel
      

      我找到了一个解决办法,但我不确定这是否是一个好的做法。我运行了以下命令$find/usr-name libgdiplus.so,但没有找到任何文件。所以我安装了libgdiplus$sudo apt get install libgdiplus,然后再次安装$find/usr-name libgdiplus.So/usr/lib/libgdiplus.So,然后我简单地将libgdiplus.So复制到/usr/local/lib.$mono WindowsFormsApplication1.exe和我得到了预期的输出。这是个好办法吗?或者,如果有任何其他建议,请分享。你将来自不同来源的mono与来自不同软件包的mono混合在一起,这会让你难堪。请阅读我找到了一个解决方案,但我不确定这是否是一个好的做法。我运行了以下命令$find/usr-name libgdiplus.so,但没有找到任何文件。所以我安装了libgdiplus$sudo apt get install libgdiplus,然后再次安装$find/usr-name libgdiplus.So/usr/lib/libgdiplus.So,然后我简单地将libgdiplus.So复制到/usr/local/lib.$mono WindowsFormsApplication1.exe和我得到了预期的输出。这是个好办法吗?或者,如果有任何其他建议,请分享。你混合了来自来源的mono和来自软件包的mono,它会咬你的屁股。请阅读感谢你的回答。你是对的。但我想编译mono的最新版本。Mono complete将安装ubuntu最新版本。谢谢您的回答。你是对的。但我想编译mono的最新版本。Mono complete将安装ubuntu最新版本。