0

我有一个适用于 Windows 7 的 C# 应用程序,但不适用于 Windows XP。当我尝试关闭程序窗口时程序崩溃。窗口关闭时没有任何额外功能,父窗口也不等待任何结果。

这是一个例外:

System.InvalidOperationException:集合已修改;枚举操作可能无法执行。
在 System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource 资源)
在 System.Collections.Generic.List 1.Enumerator.MoveNext() 在 Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(Boolean disposing) 在 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 ) 在 c:\Users\PC_Jeff_1\Desktop\sensors_file1\DataManagerv3.1\EmailSettingsForm.Designer.cs:line 241.Enumerator.MoveNextRare()
at System.Collections.Generic.List







在 System.Windows.Forms.Form.WmClose(Message& m)
在 System.Windows.Forms.Form.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms .Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

4

1 回答 1

0

我已经在 dispose 中添加了 try 块,并且不再有这个问题,但我想问题仍然存在。

堵塞:

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

        }
    }
于 2013-08-30T14:36:01.183 回答