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: [email protected]
        ReportedBy: [EMAIL PROTECTED]
         QAContact: [email protected]
          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.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to