根据this answer关于失败的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?
发布于 2013-11-07 20:20:32
谢谢乔恩,我刚找到那一页,虽然我没有逐字看,但我在里面放了一个符号链接:
sudo ln -s /usr/lib/libgdiplus.so /usr/local/lib/libgdiplus.so它解决了错误,现在mono-test-install返回:
您有一个工作的System.Drawing设置
除了语法问题外,还需要解决。
https://stackoverflow.com/questions/19845720
复制相似问题