当前位置: 代码迷 >> VB Dotnet >> System.InvalidOperationException: 集合已修改;可能无法执行枚举操作,该如何处理
  详细解决方案

System.InvalidOperationException: 集合已修改;可能无法执行枚举操作,该如何处理

热度:76   发布时间:2016-04-25 02:13:07.0
System.InvalidOperationException: 集合已修改;可能无法执行枚举操作
错误报告
————————
System.InvalidOperationException: 集合已修改;可能无法执行枚举操作。
   在 System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   在 System.Collections.Generic.List`1.Enumerator.MoveNextRare()
   在 System.Collections.Generic.List`1.Enumerator.MoveNext()
   在 Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(Boolean disposing)
   在 Microsoft.VisualBasic.PowerPacks.ShapeContainer.Dispose(Boolean disposing)
   在 System.ComponentModel.Component.Dispose()
   在 System.Windows.Forms.Control.Dispose(Boolean disposing)
   在 System.Windows.Forms.Form.Dispose(Boolean disposing)
   在 *.Form4.Dispose(Boolean disposing) 位置 E:\*\*\*\*\*\Form4.Designer.vb:行号 13
   在 System.ComponentModel.Component.Dispose()
   在 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)

关于13的代码
 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As Integer
        Dim b As Integer
        Dim c As Integer
        c = Val(TextBox3.Text)  '斜边长度
        a = Val(TextBox1.Text) '对边长度
        If c = 0 Then
            TextBox2.Text = "数值不能为0或字母"
            TextBox4.Text = "数值不能为0或字母"      '第13行
            TextBox5.Text = "数值不能为0或字母"
            TextBox1.Text = "" : TextBox3.Text = ""
            TextBox3.Focus()
            Exit Sub
        End If



已安装vs2012电脑未发现该问题,该问题出现于非安装vs的系统中(包括XP和Win7)
请问如何解决该问题

------解决方案--------------------
.NET Framework 是否已经安装?

如果没有那就安装一下。

安装vs的电脑,都安装了.NET Framework 。
------解决方案--------------------
是设计文件的十三行,看看那是什么
------解决方案--------------------
是窗体设计文件吧,不是代码文件
------解决方案--------------------
不会VB,但Private Sub 和End Sub是要对应吧?你这样也可以?
------解决方案--------------------
你的代码有问题!
看调用堆栈,System.Windows.Forms.Form.WmClose(Message& m)窗体关闭,控件开始释放,你怎么还在给控件赋值!
  相关解决方案