我在CentOS 7上安装了Mono(4.2.3)和libgdiplus(4.2),一切似乎都没问题。
mono-test-install
返回:
Active Mono: /opt/mono/bin/mono
Your have a working System.Drawing setup
Your file system watcher is: System.IO.InotifyWatcher
还编译并启动了控制台HelloWorld应用程序,没有问题,但无法运行任何winforms应用程序(包括来自Mono网站的最简单的HelloWorld示例)。它在尝试运行时给我以下消息:
Unhandled Exception: System.ArgumentException: A null reference or invalid value was found [GDI+ status: InvalidParameter]
at System.Drawing.GDIPlus.CheckStatus (Status status) <0x419aac90 + 0x0015f> in :0
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelForm
at format) <0x419fe280 + 0x00053> in :0
at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Int32 width, Int32 height) <0x41a004a0 + 0x0002f> in :0
at System.Drawing.Bitmap..ctor (System.Drawing.Image original, Size newSize) <0x41a00460 + 0x0002b> in :0
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (System.Drawing.Image,System.Drawing.Size)
at System.Windows.Forms.XplatUIX11.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) <0x419ffaf0 + 0x0020b> in :0
at System.Windows.Forms.XplatUI.DefineCursor (System.Drawing.Bitmap bitmap, System.Drawing.Bitmap mask, Color cursor_pixel, Color mask_pixel, Int32 xHotSpot, Int32 yHotSpot) <0x419ffa70 + 0x00070> in :0
at System.Windows.Forms.Cursor.CreateCursor (System.IO.Stream stream) <0x419fc0e0 + 0x00193> in :0
at System.Windows.Forms.Cursor..ctor (System.Type type, System.String resource) <0x419fbea0 + 0x0006b> in :0
at System.Windows.Forms.Cursors.get_SizeNWSE () <0x419fbd40 + 0x0005b> in :0
at System.Windows.Forms.SizeGrip..ctor (System.Windows.Forms.Control CapturedControl) <0x419fbcb0 + 0x0001f> in :0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.SizeGrip:.ctor (System.Windows.Forms.Control)
at System.Windows.Forms.ScrollableControl.CreateScrollbars () <0x419f8e40 + 0x004ff> in :0
at System.Windows.Forms.ScrollableControl..ctor () <0x419a5e30 + 0x00387> in :0
at System.Windows.Forms.ContainerControl..ctor () <0x419a5ca0 + 0x00027> in :0
at System.Windows.Forms.Form..ctor () <0x419a5420 + 0x000bb> in :0
at HelloWorld..ctor () <0x419a2fa0 + 0x0000f> in :0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () <0x419a2d90 + 0x0001f> in :0
尝试也跑
MONO_LOG_LEVEL="debug" MONO_LOG_MASK="dll" mono test.exe
它找到了所需的所有库。在互联网上找不到类似的消息但在任何地方都找不到解努力使用我的大脑仍然没有。前段时间我在同一系统中安装了相同版本的Mono,但是其他机器也运行得很好。无论我是通过yum安装还是从源代码编译,都会显示此消息。
答案 0 :(得分:-1)
这似乎是System.Drawing DLL的问题,类似于another answer I wrote。
首先,找到System.Drawing.dll文件所在的目录(例如
/opt/mono-4.4.0/lib/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
)
使用以下内容在名为System.Drawing.dll.config
的同一目录中创建文件,将目录更新为libgdiplus.so
的正确位置:
<configuration>
<dllmap dll="gdiplus.dll" target="/opt/mono-4.4.0/lib/libgdiplus.so"/>
</configuration>