[Mono-bugs] [Bug 355074] New: Control.Dispose removes control from parent.Controls
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Mon Jan 21 05:57:39 EST 2008
https://bugzilla.novell.com/show_bug.cgi?id=355074
Summary: Control.Dispose removes control from parent.Controls
Product: Mono: Class Libraries
Version: 1.2.6
Platform: PC
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Windows.Forms
AssignedTo: mono-bugs at lists.ximian.com
ReportedBy: adam_misc at yahoo.co.uk
QAContact: mono-bugs at lists.ximian.com
Found By: Other
Created an attachment (id=191179)
--> (https://bugzilla.novell.com/attachment.cgi?id=191179)
Source code for mini-program that exhibits the bug.
This is my first Mono bug report, so apologies if I haven't done it right. I'm
a .NET programmer trying Mono out of interest.
Description of Problem:
Control.Dispose removes the control from parent.Controls (see Control.cs around
line 1098 "parent.Controls.Remove(this);"). Arguably this is reasonable
enough, but it is different from .NET, so creates porting problems.
In particular, under Mono, the following code fails with "Exception: List has
changed."
foreach (Control lControl in Controls) lControl.Dispose();
Steps to reproduce the problem:
1. (See attachment for sample code.) Create a form with a button. Add a click
handler for the button that contains the above loop.
2. Launch under Mono.
3. Click the button.
Actual Results:
Application terminates. On my PC, there is no output, it just dies. But if I
wrap the code in an exception handler, the cause is "Exception: List has
changed."
Expected Results:
The button disappears from the form, and the application continues.
How often does this happen?
Always.
Additional Information:
I can of course rewrite my program to work correctly in both Mono and .NET by
taking a copy of Controls, and looping over that. See the comment "FIX:" in
the attachment. But if Mono aims that .NET programs will "just work" as far as
possible, it would be better to mimic the behavior of .NET.
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
More information about the mono-bugs
mailing list