我正在修改集合;每次我尝试关闭此表单时,枚举操作可能不会执行错误。我怀疑它与我在起始形式(Details1)中声明的StringBuilder()有关。我已经花了几个小时寻找问题。只有当我在其他机器上安装时,它才会在调试时抛出错误。
请帮忙。
> Public Class PLocation
>
> Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
> Label2.Text = ""
> Dim showForm As Form = My.Settings.PreviousForm
> showForm.Show()
> Me.Hide()
> End Sub
>
> Private Sub PLocation_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
> Label2.Text = ""
> Label1.Text = My.Settings.CurrentProject1
> Label6.Text = My.Settings.UserInitials1
> Label5.Text = My.Settings.CurrentDataPath1
> Label7.Text = My.Settings.EquipID1
> Label8.Text = My.Settings.CurrentPunchItem1
> Home.Details1.Clear()
>
> End Sub
>
> Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
> Dim ExitBox As MsgBoxResult = MessageBox.Show("Are you sure you want to CLOSE this program?", _
> "WARNING", _
> MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
>
> 'If Yes, then delete
> If ExitBox = MsgBoxResult.Yes Then
> Home.Close()
>
> End If
> End Sub
>
>
>
> Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
> If TextBox1.Text.Contains(",") Then
> Label2.Text = "Remove commas in comment box."
> Else
> Label2.Text = ""
> If CheckBox1.Checked Then
> Home.Details1.Append("Breakover; ")
> End If
>
> If CheckBox2.Checked Then
> Home.Details1.Append("Chute; ")
> End If
>
> If CheckBox3.Checked Then
> Home.Details1.Append("Drive pulley; ")
> End If
>
> If CheckBox4.Checked Then
> Home.Details1.Append("End pulley; ")
> End If
> If CheckBox5.Checked Then
> Home.Details1.Append("Return roller; ")
> End If
> If CheckBox6.Checked Then
> Home.Details1.Append("Sideguard; ")
> End If
> If CheckBox7.Checked Then
> Home.Details1.Append("Slider bed; ")
> End If
> If CheckBox8.Checked Then
> Home.Details1.Append("Snub; ")
> End If
> If CheckBox9.Checked Then
> Home.Details1.Append("Take-up; ")
> End If
> If CheckBox10.Checked Then
> Home.Details1.Append("Head end; ")
> End If
> If CheckBox11.Checked Then
> Home.Details1.Append("Tail end; ")
> End If
> If CheckBox12.Checked Then
> Home.Details1.Append("Drive section; ")
> End If
> If CheckBox13.Checked Then
> Home.Details1.Append("Middle; ")
> End If
> If CheckBox14.Checked Then
> Home.Details1.Append("Left side; ")
> End If
> If CheckBox15.Checked Then
> Home.Details1.Append("Right side; ")
> End If
> If CheckBox16.Checked Then
> Home.Details1.Append("at joint ; ")
> End If
> If CheckBox17.Checked Then
> Home.Details1.Append("Top side; ")
> End If
> If CheckBox18.Checked Then
> Home.Details1.Append("Bottom side; ")
> End If
> If CheckBox19.Checked Then
> Home.Details1.Append("Insider / Inner; ")
> End If
> If CheckBox20.Checked Then
> Home.Details1.Append("Outside / Outer; ")
> End If
> If CheckBox21.Checked Then
> Home.Details1.Append("Above; ")
> End If
> If CheckBox22.Checked Then
> Home.Details1.Append("Below; ")
> End If
> If CheckBox23.Checked Then
> Home.Details1.Append("Lower; ")
> End If
> If CheckBox24.Checked Then
> Home.Details1.Append("Upper; ")
> End If
> If CheckBox27.Checked Then
> Home.Details1.Append("Bad installation; ")
> End If
> If CheckBox28.Checked Then
> Home.Details1.Append("Bent; ")
> End If
> If CheckBox29.Checked Then
> Home.Details1.Append("Damaged; ")
> End If
> If CheckBox30.Checked Then
> Home.Details1.Append("Dented; ")
> End If
> If CheckBox31.Checked Then
> Home.Details1.Append("Gap; ")
> End If
> If CheckBox32.Checked Then
> Home.Details1.Append("Incomplete; ")
> End If
> If CheckBox33.Checked Then
> Home.Details1.Append("Insufficient; ")
> End If
> If CheckBox34.Checked Then
> Home.Details1.Append("Loose; ")
> End If
> If CheckBox35.Checked Then
> Home.Details1.Append("Misaligned; ")
> End If
> If CheckBox36.Checked Then
> Home.Details1.Append("No access; ")
> End If
> If CheckBox37.Checked Then
> Home.Details1.Append("Uneven; ")
> End If
> If CheckBox38.Checked Then
> Home.Details1.Append("Not installed; ")
> End If
> If CheckBox39.Checked Then
> Home.Details1.Append("Not straight; ")
> End If
> If CheckBox40.Checked Then
> Home.Details1.Append("Rusted; ")
> End If
> If CheckBox41.Checked Then
> Home.Details1.Append("Sharp edges; ")
> End If
> If CheckBox42.Checked Then
> Home.Details1.Append("Too large; ")
> End If
> If CheckBox43.Checked Then
> Home.Details1.Append("Too long; ")
> End If
> If CheckBox44.Checked Then
> Home.Details1.Append("Too short; ")
> End If
> If CheckBox45.Checked Then
> Home.Details1.Append("Too Small; ")
> End If
> If CheckBox46.Checked Then
> Home.Details1.Append("Wrong type; ")
> End If
> If CheckBox47.Checked Then
> Home.Details1.Append("Wrong color; ")
> End If
> If CheckBox48.Checked Then
> Home.Details1.Append("Wrong size; ")
> End If
> If CheckBox25.Checked Then
> Home.Details1.Append("times 2; ")
> End If
> If CheckBox26.Checked Then
> Home.Details1.Append("times 3; ")
> End If
> If TextBox1.Text = "" Then
> 'do nothing
> Else
> Home.Details1.Append(", " & TextBox1.Text)
> End If
>
> Home.Details2 = Home.Details1.ToString
> Summary.Show()
> Me.Close()
>
> End If
> End Sub
>
>
>
> Private Sub Label16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
> About.Show()
> End Sub
>
>
> End Class
>
** * ** 异常文字 ** * **** System.InvalidOperationException:修改了集合;列举 操作可能无法执行。在 System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource 资源) System.Collections.Generic.List
1.Enumerator.MoveNextRare() at System.Collections.Generic.List
1.Enumerator.MoveNext()at Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(布尔 处理) Microsoft.VisualBasic.PowerPacks.ShapeContainer.Dispose(布尔 处理)在System.ComponentModel.Component.Dispose()at System.Windows.Forms.Control.Dispose(布尔处理)at System.Windows.Forms.Form.Dispose(布尔处理)at WindowsApplication1.PLocation.Dispose(布尔处理)在 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) 在System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd,Int32) msg,IntPtr wparam,IntPtr lparam)
答案 0 :(得分:0)
这是一个奇怪的问题。我无法根据您发布的信息确定可能导致的原因。我也无法在这里重现这个问题。它确实看起来你的表单上有很多控件,但这不是必然的问题,但它可能有所贡献。
如果您愿意,请随时直接向我发送电子邮件John.Hart @ Microsoft.com,我们将离线,看看我们是否可以找到它的底部。
谢谢, 约翰