如何完全关闭showdialog?

时间:2017-09-06 13:25:39

标签: vb.net winforms dispose showdialog

我创建了一个我无法真正使用表单的显示/隐藏功能的过程。这就是为什么我现在正在使用Showdialog。

我用来创建下一个表单(并关闭/处理下一个表单)的代码是:

Private Sub btnControle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnControle.Click
    Try
        Dim frmlocatie As New frmLocatie
        Me.Close()
        Me.Dispose(True)
        frmlocatie.ShowDialog()
    Catch ex As Exception
        MessageBox.Show(ex.ToString)
    End Try
End Sub

在我的应用程序中,我必须能够从任何地方访问7种表单中的一种。 关于申请的一些额外信息: 我们必须选择一个位置,选择子位置,选择房间,然后选择项目。从这些形式中,我们可以点击“位置”,例如选择另一个。

enter image description here

目前我的主要问题是,在大约20个表单打开+关闭后,系统会在随机表单上构建错误(同时构建它)并且说: StackoverflowException未处理:发生了类型为“System.StackoverflowException”的未处理异常。 enter image description here

我认为这是因为扫描仪存在内存问题,而且没有正确关闭表单。 (即使关闭+处置)

非常感谢任何帮助。

编辑:根据我使用调用堆栈的注释,请参见下面的图片。 enter image description here

我还尝试了其他评论并抓住了错误:

?ex.ToString
"System.StackOverflowException: StackOverflowException
bij Microsoft.AGL.Forms.WL.SetPos()
bij System.Windows.Forms.Control._SetBoundsCore()
bij System.Windows.Forms.Control.set_Size()
bij OpenNETCF.Windows.Forms.BatteryLife..ctor()
bij BradyPDT.frmLocatie.InitializeComponent()
bij BradyPDT.frmLocatie..ctor()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLocatie.lblLocatie_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.LinkLabel.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmMain.btnControle_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterModalDialog()
bij System.Windows.Forms.Form.ShowDialog()
bij BradyPDT.frmLogin.btnNext_Click()
bij System.Windows.Forms.Control.OnClick()
bij System.Windows.Forms.Button.OnClick()
bij System.Windows.Forms.ButtonBase.WnProc()
bij System.Windows.Forms.Control._InternalWnProc()
bij Microsoft.AGL.Forms.EVL.EnterMainLoop()
bij System.Windows.Forms.Application.Run()
bij BradyPDT.frmSplash.Main()
"

0 个答案:

没有答案