How to debug application restart in Visual Studio?

I am creating a Visual Basic application in Visual Studio 2010. Some of my options can only be applied when the application restarts.

I did not get a single crash when the application is working fine. Also it does not work when I apply the settings, manually exit and restart. On the other hand, as soon as I try to perform an automatic restart from the application, I get an exception from one of 5-10 restarts.

I tried to start the debugger, but as soon as the application restarts, the Visual Studio debugger will turn off and will not turn on when the application starts again. And it does not start again with the same configurations. It seems that the debugger started the application configuration, and the application configuration files manually were different.

Is there any way around this? Support debugger through reboots? Or should I take on a different strategy?

+4
source share
1 answer

Method 1: Attach the debugger from the application

If the application sometimes crashes on startup, add a call to the application event . This will cause Visual Studio to open a window where you can attach its debugger. Debugger.Launch() Startup

You can check the property to determine if the debugger is attached or not. Debugger.IsAttached

Steps to subscribe to an event Startup:

  • Right-click your project in Solution Explorerand click Properties.

  • Application.

  • View Application Events.

  • MyApplication (events) .

  • Startup .

:

Imports System.Diagnostics

...

Private Sub MyApplication_Startup(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupEventArgs) Handles Me.Startup
    If Debugger.IsAttached = False Then
        Debugger.Launch()
    End If
End Sub

2: Windows , , ,

, , .

. Windows , . , , .

Malwarebytes : .

:

  • Regedit.

  • HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Image File Execution Options.

  • ( ) yourApplicationName.exe.

  • String (REG_SZ) debugger.

  • debugger vsjitdebugger.exe.

  • !

. : - MSDN

+1

Source: https://habr.com/ru/post/1681288/


All Articles