A_kat
A_kat

Reputation: 1527

How to debug an exe with multiple dlls using breakpoints

I have a myapp.exe that after some complicated logic is run by another program. I wanted to debug the issues with myapp.exe just like visual studio preferably using breakpoints. What is the way to achieve this? The exe is a console application and is run on the spot. It's not a running process so I cant attach a debugger.

The expected behavior I would want is:

Upvotes: 0

Views: 306

Answers (1)

PaoloTa
PaoloTa

Reputation: 478

Just use System.Diagnostics.Debugger.Launch() where you want to attach the debugger. You can place it just before your desired breakpoint location. Windows will ask you what debugger do you want to attach.

Another way is to check the System.Diagnostics.Debugger.IsAttached property and wait for the debugger like this (polling):

while (!Debugger.IsAttached)
{
    Thread.Sleep(500);
}

The application will loop until you attach the debugger (in visual studio via attach to process command, Ctrl+alt+P ). Again, just place a break point after or even in the loop and you're done.

This is a well know way used to debug a windows service application and can be useful also for your intent.

Upvotes: 1

Related Questions