繁体   English   中英

无法在CentOS 7上运行WinForms Mono应用程序

[英]Can't run WinForms Mono application on CentOS 7

我已经在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安装还是从源代码编译,都会显示此消息。

这似乎是System.Drawing DLL的问题,类似于我写的另一个答案

首先,找到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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM