[Mono-winforms-list] Probably bug in SetSystemColors
Sebastien Pouliot
sebastien at ximian.com
Tue May 8 13:10:09 EDT 2007
On Tue, 2007-05-08 at 11:47 -0400, Maser, Dan wrote:
>
> 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;
> }
This has been changed, last week, to accept an int.
> 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.
Just update from SVN and this should work without problem.
--
Sebastien Pouliot <sebastien at ximian.com>
Blog: http://pages.infinit.net/ctech/
More information about the Mono-winforms-list
mailing list