【问题标题】:Unhandled Exception while running .exe on mono framework in Ubuntu 13.04在 Ubuntu 13.04 的单声道框架上运行 .exe 时出现未处理的异常
【发布时间】:2018-09-29 05:53:06
【问题描述】:

我使用的是 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

如何删除此异常,请帮助我。 提前致谢。

【问题讨论】:

  • 我找到了一个解决方案,但我不确定这是一个好习惯。我运行了以下命令 $ 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-project.com/Parallel_Mono_Environments

标签: mono


【解决方案1】:

正如@knocte 指出的那样,你应该

  • 通过apt-get如sudo apt-get install mono-complete安装Mono,这样libgdiplus也安装好了,
  • 或者从源代码编译 libgdiplus 和 Mono。

【讨论】:

  • 感谢您的回答。你说的对。但我想编译最新版本的单声道。 Mono-complete 将安装最新的 ubuntu 版本。
【解决方案2】:

raffamaiden 的回答对我有用,但回答中有一个小的拼写错误:

dnf install libgdiplus-devel

【讨论】:

    【解决方案3】:

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

    dnf install libgdiplus-devel
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-06-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-22
      • 1970-01-01
      相关资源
      最近更新 更多