如何以编程方式在Visual Studio中分离调试器

时间:2021-06-21 20:45:23

I just want to detach my debugger when exiting my application in Visual Studio. Upon closing, the cleanup process takes a few seconds and I don't want to wait. I'm working in VB.net:

我只是想在Visual Studio中退出我的应用程序时分离我的调试器。关闭后,清理过程需要几秒钟,我不想等待。我在VB.net工作:

Private Sub frmBladeAlignment_FormClosing(ByVal sender As Object,
                                          ByVal e As FormClosingEventArgs) Handles MyBase.FormClosing
    Select Case e.CloseReason
        Case CloseReason.UserClosing
            Select Case MessageBox.Show("Are you sure you wish to exit?", "Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
                Case DialogResult.Yes
                    e.Cancel = False
                Case DialogResult.No
                    e.Cancel = True
            End Select
        Case else
            e.Cancel = False
    End Select

    If Not e.CancelThen
        Me.Enabled = False
        Me.Text = "APPLICATION IS CLOSING"
        Application.DoEvents()
        If Debugger.IsAttached Then
            ' detach debugger here
        End If
    End If
End Sub

' this is an MDI application and many operations 
' are done in child forms when the main form 
' is closing

I have looked in the System.Diagnostics.Debugger class, but found nothing useful.

我查看了System.Diagnostics.Debugger类,但没有发现任何有用的东西。

http://msdn.microsoft.com/en-us/library/System.Diagnostics.Debugger.aspx

http://msdn.microsoft.com/en-us/library/System.Diagnostics.Debugger.aspx

1 个解决方案

#1


1  

Looks like you have to use a win32 API call, have a look at the following links

看起来您必须使用win32 API调用,请查看以下链接

http://blogs.msdn.com/b/jmstall/archive/2006/03/09/detach-restrictions.aspx Programmatically detach debugger

http://blogs.msdn.com/b/jmstall/archive/2006/03/09/detach-restrictions.aspx以编程方式分离调试器

#1


1  

Looks like you have to use a win32 API call, have a look at the following links

看起来您必须使用win32 API调用,请查看以下链接

http://blogs.msdn.com/b/jmstall/archive/2006/03/09/detach-restrictions.aspx Programmatically detach debugger

http://blogs.msdn.com/b/jmstall/archive/2006/03/09/detach-restrictions.aspx以编程方式分离调试器