1

我通过从表单中删除线条形状来解决此问题。

原帖

当我的表单关闭时,我收到以下错误:

System.InvalidOperationException:集合已修改;枚举操作可能无法执行

这仅在程序部署在机器上而不是在调试期间出现。如果我隐藏表单,它不会仅在表单关闭时发生。

非常感谢任何帮助,因为这现在变得非常烦人。在此先感谢,
克雷格

ps 下面是 FormClosed 事件

    'Disconnect from database
    cn.Close()
    cn.Dispose()

堆栈跟踪

   ************** Exception Text **************
   System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.List`1.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.ComponentModel.Component.Dispose()
   at System.Windows.Forms.Control.Dispose(Boolean disposing)
   at System.Windows.Forms.TabControl.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 EquiManager.frmEditJumpingShow.Dispose(Boolean disposing)
   at System.ComponentModel.Component.Dispose()
   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)
4

1 回答 1

0

我删除了线条形状,错误消失了。

于 2013-07-22T19:39:47.983 回答