首页 > 解决方案 > VB .NET 堆栈溢出 System.StackOverflowException

问题描述

单击表单上的 X 以关闭后,出现堆栈溢出。它发生在表单关闭事件之后。我正在使用 Visual Studio 2017 和 VB .NET。任何想法如何追踪这一点?调用堆栈似乎很小导致溢出。另外,为什么要组装,当我双击时,甚至调用堆栈中的东西都会为我组装。错误:

        System.StackOverflowException
  HResult=0x800703E9
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

我的代码:

  Private Sub frmViewAll_FormClosed(ByVal eventSender As System.Object, ByVal eventArgs As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Try
            formClosing_Renamed = True
            'JC.Global.StudyForm.Activate() 
        Catch ex As Exception

        End Try
    End Sub

汇编:00007FF9204C150D mov byte ptr [rbx+0Ch],1

调用堆栈:

[Managed to Native Transition]  
>   System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DefWndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Form.DefWndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Control.WndProc(ref System.Windows.Forms.Message m)   Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Form.WmSysCommand(ref System.Windows.Forms.Message m) Unknown
    DevExpress.Utils.v17.1.dll!DevExpress.XtraEditors.DForm.WndProc(ref System.Windows.Forms.Message m) Unknown
    DevExpress.Utils.v17.1.dll!DevExpress.XtraEditors.XtraForm.WndProc(ref System.Windows.Forms.Message msg)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.DebuggableCallback(System.IntPtr hWnd, int msg, System.IntPtr wparam, System.IntPtr lparam)  Unknown
    [Native to Managed Transition]  
    [Managed to Native Transition]  
    System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(System.IntPtr dwComponentID, int reason, int pvLoopData)  Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason, System.Windows.Forms.ApplicationContext context)    Unknown
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Unknown
    Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun() Unknown
    Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()    Unknown
    Microsoft.VisualBasic.dll!Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(string[] commandLine)   Unknown

我能够将代码简化为这个并且仍然得到错误,所以它必须是一个设计器问题:

Friend Class frmTestForm
    Inherits DevExpress.XtraEditors.XtraForm
    Public Sub setMode(test As Boolean)

    End Sub

End Class

注释掉所有内容的设计师仍然存在问题:

<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> Partial Class frmTestForm

#Region "Windows Form Designer generated code "

    ' <System.Diagnostics.DebuggerNonUserCode()>
    Public Sub New()
        MyBase.New()


        'This call is required by the Windows Form Designer.
        InitializeComponent()
    End Sub


    'Form overrides dispose to clean up the component list.
    '<System.Diagnostics.DebuggerNonUserCode()>
    Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
        If Disposing Then
            If Not components Is Nothing Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose()
    End Sub
    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer
    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.
    'Do not modify it using the code editor.
    '<System.Diagnostics.DebuggerStepThrough()>
    Private Sub InitializeComponent()
        'Me.SuspendLayout()
        '
        'frmTestForm
        '
        'Me.Appearance.Options.UseFont = True
        'Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 14.0!)
        'Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.ClientSize = New System.Drawing.Size(984, 575)
        'Me.Cursor = System.Windows.Forms.Cursors.Default
        'Me.Font = New System.Drawing.Font("Arial", 8.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
        'Me.Location = New System.Drawing.Point(286, 233)
        'Me.MinimumSize = New System.Drawing.Size(650, 450)
        'Me.Name = "frmTestForm"
        'Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
        'Me.Text = "View All Questions/Answers"
        'Me.ResumeLayout(False)
        'Me.PerformLayout()

    End Sub
    'Friend WithEvents txtSearch As System.Windows.Forms.TextBox
#End Region
End Class

MyBase.Dispose() 上发生错误

标签: vb.netvisual-studio

解决方案


推荐阅读