1

根据这个关于失败结果的答案mono-test-install,我将以下内容放入test.cs

using System;
using System.Drawing;

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

然后跑了

mcs -pkg:dotnet test.cs

输出:

test.cs(7,16): 警告 CS0219: 变量“b”被赋值,但它的值从未使用过编译成功 - 1 个警告

并使用以下命令运行生成的 exe:

mono test.exe

输出:

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 

忽略这一点是否安全,或者我应该NotFoundException: /usr/local/lib/libgdiplus.so接下来调试该行吗?

4

1 回答 1

3

谢谢乔恩,我刚刚找到了那个页面,虽然我没有逐字逐句地遵循它,但我在其中添加了一个符号链接:

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

解决了错误,现在mono-test-install返回:

您有一个有效的 System.Drawing 设置

除了语法问题,它应该得到解决。

于 2013-11-07T20:20:32.487 回答