mono mac osx csharp win形式gdi字体例外,但不使用任何MS字体



我们正在尝试在我们重写的Mac OSX上运行c# Win Form应用程序。在之前的版本中,所有与win form相关的东西都可以工作,但现在我们在Mac上看到了:

Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.ArgumentException: The requested FontFamily could not be found [GDI+ status: FontFamilyNotFound]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.FontFamily..ctor (GenericFontFamilies genericFamily) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.FontFamily:.ctor (System.Drawing.Text.GenericFontFamilies)
  at System.Drawing.FontFamily.get_GenericSansSerif () [0x00000] in <filename unknown>:0 
  at System.Drawing.Font.CreateFont (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, System.String systemName) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Font:.ctor (string,single,string)
  at System.Drawing.SystemFonts.get_DefaultFont () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Theme..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeWin32Classic..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeVisualStyles..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 
  at NewWorldStudio.StartupForm..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) NewWorldStudio.StartupForm:.ctor ()
  at NewWorldStudio.Program.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.WindowsFormsSynchronizationContext ---> System.TypeInitializationException: An exception was thrown by the type initializer for System.Windows.Forms.ThemeEngine ---> System.ArgumentException: The requested FontFamily could not be found [GDI+ status: FontFamilyNotFound]
  at System.Drawing.GDIPlus.CheckStatus (Status status) [0x00000] in <filename unknown>:0 
  at System.Drawing.FontFamily..ctor (GenericFontFamilies genericFamily) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.FontFamily:.ctor (System.Drawing.Text.GenericFontFamilies)
  at System.Drawing.FontFamily.get_GenericSansSerif () [0x00000] in <filename unknown>:0 
  at System.Drawing.Font.CreateFont (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) [0x00000] in <filename unknown>:0 
  at System.Drawing.Font..ctor (System.String familyName, Single emSize, System.String systemName) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Drawing.Font:.ctor (string,single,string)
  at System.Drawing.SystemFonts.get_DefaultFont () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Theme..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeWin32Classic..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeVisualStyles..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
  at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unknown>:0 
  at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0 
  at NewWorldStudio.StartupForm..ctor () [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) NewWorldStudio.StartupForm:.ctor ()
  at NewWorldStudio.Program.Main () [0x00000] in <filename unknown>:0 

很难在谷歌上找到解决方案。根据堆栈跟踪中的get_GenericSansSerif方法,它似乎与GDI+和SansSerif字体有关。

可能是Mono设置不好造成的。尝试重新安装并检查是否在OS x上安装了X11。

最新更新