0
votes

I have a C# app which works on Windows 7, but does not work on Windows XP. The program crashes when I try to close a program window. The window doesn't have any extra functions when closing, and the parent window is not waiting for any results.

Here is the exception:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
at System.Collections.Generic.List1.Enumerator.MoveNextRare()
at System.Collections.Generic.List
1.Enumerator.MoveNext()
at Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(Boolean disposing)
at Microsoft.VisualBasic.PowerPacks.ShapeContainer.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at System.Windows.Forms.Control.Dispose(Boolean disposing)
at System.Windows.Forms.Form.Dispose(Boolean disposing)
at DataManager.EmailSettingsForm.Dispose(Boolean disposing) in c:\Users\PC_Jeff_1\Desktop\sensors_file1\DataManagerv3.1\EmailSettingsForm.Designer.cs:line 24
at System.Windows.Forms.Form.WmClose(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

1
Can you please reformat that wall of random text?chrylis -cautiouslyoptimistic-
Please include the code in the Dispose(bool disposing) method in c:\Users\PC_Jeff_1\Desktop\sensors_file1\DataManagerv3.1\EmailSettingsForm.Designer.csScott Chamberlain
protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); }Виктор Синявский

1 Answers

0
votes

I've added try block in dispose and a'm not having that issue any more, but I guess problem still is here.

Block:

    protected override void Dispose(bool disposing)`
    {
        try
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        catch
        {

        }
    }