2013-10-25 54 views
5

我在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> 

请让我知道,如果有人在过去的偶然发现了这一点。

+0

为什么使用WinForm? WinForm不是完全用单声道实现的。此外,GTK#应用程序在Linux上看起来更为原生。 – Deffiss

回答

3

你已经追查错误。 您的单声道版本不支持EnableVisualStyles。 升级到一个支持它的版本(据我所知它是> = 2.9),或者尝试在你的.net应用程序中禁用这个功能,这将导致“不那么好的UI元素”。 对我来说,它工作,因为我正在研究gentoo。突然,在出现之后,我的单声道应用程序不再崩溃。

1

另外请确保libgdiplus.so.0实际上已安装并且在路径上,它不是默认情况下在单声道。但是,是的,主要的是CentOS默认配备了过时的单声道版本。

相关问题