Stylecop addin throw exception System.TypeInitializationException: The requested FontFamily could not be found [GDI+ status: FontFamilyNotFound]

Hi guys,

I managed to use stylecop (a static code analysis tool supported in MonoDevelop/VS by Microsoft) in MonoDevelop-Unity as an addin. It was installed successfully with just a few warnings, and the code check could work, however, when I tried to open “Stylecop Settings”, I always got the following exception.

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 :0
at System.Drawing.FontFamily…ctor (GenericFontFamilies genericFamily) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Drawing.FontFamily:.ctor (System.Drawing.Text.GenericFontFamilies)
at System.Drawing.FontFamily.get_GenericSansSerif () [0x00000] in :0
at System.Drawing.Font.CreateFont (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte charSet, Boolean isVertical) [0x00000] in :0
at System.Drawing.Font…ctor (System.String familyName, Single emSize, FontStyle style, GraphicsUnit unit, Byte gdiCharSet, Boolean gdiVerticalFont) [0x00000] in :0
at System.Drawing.Font…ctor (System.String familyName, Single emSize, System.String systemName) [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Drawing.Font:.ctor (string,single,string)
at System.Drawing.SystemFonts.get_DefaultFont () [0x00000] in :0
at System.Windows.Forms.Theme…ctor () [0x00000] in :0
at System.Windows.Forms.ThemeWin32Classic…ctor () [0x00000] in :0
at System.Windows.Forms.ThemeEngine…cctor () [0x00000] in :0
— End of inner exception stack trace —
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in :0
at System.Windows.Forms.Control…ctor () [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext…cctor () [0x00000] in :0

According to mono addin webpage, I already installed X11 with latest version, and my box is a MBP with Mavericks 10.9, Unity3D 4.3(MonoDevelop-Unity 4.0.1) installed.

Stylecop addin for mono http://addins.monodevelop.com/Project/Index/54

I really want to use this powerful addin in my MAC, anyone hit the same issue like me? Do you have any workaround to fix?

Thanks!

Hey did you get this working? I am having the same issue!

1 Answer

1

Some digging suggests that WinForms may be looking for a font named “MS Sans Serif”. Checking my system, I see I have “MS Reference Sans Serif”, and “Microsoft Sans Serif”, but nothing actually named “MS Sans Serif”, which is consistent with this possibility.