我在Visual Studio 2010的C#.Net中开发了一个使用WinForm的测试应用程序。现在,我想在Linux下使用Mono在CentOS上运行此应用程序。所以,我想下面的命令序列 -在CentOS或Linux上使用Mono执行.Net应用程序
[[email protected] TestLinux]# /usr/bin/mono ./Test.exe
我打了一个异常
Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.XplatUI ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: gdiplus.dll
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor() [0x00000] --- End of inner exception stack trace ---
at <0x00000> <unknown method>
at System.Drawing.Graphics.FromHdcInternal (IntPtr hdc) [0x00000]
at System.Windows.Forms.XplatUIX11.SetDisplay (IntPtr display_handle) [0x00000]
at System.Windows.Forms.XplatUIX11..ctor() [0x00000]
at System.Windows.Forms.XplatUIX11.GetInstance() [0x00000]
at System.Windows.Forms.XplatUI..cctor() [0x00000] --- End of inner exception stack trace ---
at <0x00000> <unknown method>
at System.Windows.Forms.Application.EnableVisualStyles() [0x00000]
at Test.Program.Main() [0x00000]
虽然做了一些研究,我发现,这是由于gdiplus.dll的和其抗衡部分libgdiplus.so.0之间的链接在Linux上,需要将其条目放入ldconfig缓存中。
[[email protected] TestLinux]# ldconfig -p | grep libgdiplus
libgdiplus.so.0 (libc6) => /usr/lib/libgdiplus.so.0
输出清楚地表明,libgdiplus.so.0有ldconfig的缓存,但仍计划是行不通的。我也试图在应用程序配置中添加DllMap进入如下
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
<dllmap dll="gdiplus.dll" target="libgdiplus.so.0"/>
</configuration>
请让我知道,如果有人在过去的偶然发现了这一点。
为什么使用WinForm? WinForm不是完全用单声道实现的。此外,GTK#应用程序在Linux上看起来更为原生。 – Deffiss