Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report for Bug 15539 on
GitHub or Developer Community if you have new
information to add and do not yet see a matching new report.
If the latest results still closely match this report, you can use the
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
Tested on 3.2.0 and 3.2.3.
Some times the Paint event is triggered while running on Mac OS X.
See code below:
protected override void OnPaint (System.Windows.Forms.PaintEventArgs e)
Control parent = this.Parent;
while (parent != null)
// is only run when using Mono on Mac OS X.
Console.WriteLine ("OnPaint: Run while parent is not visible.");
parent = parent.Parent;
. . .
The real painting code.
The Console.WriteLine is not run when using Mono on Windows or using Microsoft .NET.
The reproduction scenario includes a second form to be loaded, before this issue arise.
* Form1 has two panels and two buttons.
- Button1 to switch between panels (bool showPanel1 = !panel1.Visible; panel1.Visible = showPanel1; panel2.Visible = !showPanel1;)
- Button2 to show Form2 with ShowDialog
* UserControl with code from above on both panels.
* Form2 empty
Start program with Form1.
* Click button 1 to hide panel 1 and show panel 2.
* Click button 2 to open Form2 as Dialog.
* Now it runs Console.WriteLine for every UserControl on the hidden panel1.
* Close Form2.
* Now it runs Console.WriteLine again for every UserControl on the hidden panel1.
I have seen the bug now also happening without using an extra form. But simply by switching to other applications and switching back.
Not sure whether this is related. While testing, on my console I see between the many lines "OnPaint: Run while parent is not visible." I see several lines:
mono[...] <Error>: kCGErrorInvalidConnection: CGSGetWindowTags: Invalid connection
After the first invalid connection line it also prints:
mono[...] <Error>: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
For me it is not clear how to get the real error and / or setting the breakpoint.
Some more information.
For the record, I am running Mac OS X 10.7.5.
I discovered that this behaviour only occurs with implementations of UserControl. Having ordinary Button controls on the panels is working fine.
Secondly, even with the .Visible of the UserControl on false the UserControl is painted.
I will try to make a simple project next month to make the bug reproducible for you.
This issue might be a duplicate of bug #3124.
Setting priority to lowest, since Windows.Forms is no longer being developed actively.