gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-03 01:41:39 25 4
gpt4 key购买 nike

我已经在我的 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 的问题,类似于 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>

关于c# - 无法在 CentOS 7 上运行 WinForms Mono 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37656985/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com