I was investigation my colors problem and I noticed this printed to my
console window:
   "Gtk colorscheme read failure, using built-in colorscheme"

  I investigated that code and found a probably bug.  In the file
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs there is
this function, starting near line 207:

private void SetSystemColors(KnownColor kc, Color value)
{
    if (update == null)
    {
       Type known_colors = Type.GetType("System.Drawing.KnownColors," +
Consts.AssemblySystem_Drawing);
       if (known_colors != null)
       {
           update = known_colors.GetMethod("Update", BindingFlags.Static
| BindingFlags.Public);
       }
    }
    if (update != null)
    {
        update.Invoke (null, new object[2] { (int)kc, value.ToArgb() });
    }
}


Which uses reflection to invoke the KnownColors.Update method.   In the
last line the "Color.ToArgb()" function returns an int.  However, the
function signature of Update is:

public static void Update (int knownColor, uint color)
{
    ArgbValues[knownColor] = color;
}

Which expects a uint as the second parameter, not an int.  This throws a
System.ArgumentException.   I verified that if the last line of
SetSystemColors is changed to

    if (update != null)
    {
        update.Invoke (null, new object[2] { (int)kc,
(uint)value.ToArgb() });
    }

Then the exception no longer happens, and the warning is no longer
printed to my console window when launching mono apps.

_______________________________________________
Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-winforms-list

Reply via email to