Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio debug child process on its startup

I have a WPF Application after it is loading (some WCF services) and I am running a child process (Gui less Windows Application). Both projects are in my solution.

I wish to debug both of them. I know I can debug two projects if I set both of with action = start in the solution properties under "Multiple startup projects".

But this is not the case since the WPF app is starting the child process after X time. And I cannot "Attach to process" since I want to catch the main method of the child process.

Is there a solution?

What I did so far was to disable the CreateNewProcess() method, place a breakpoint where it should occur, and manually debug the project, and then continue the WPF app from that breakpoint, using two visual studios.

like image 607
ilansch Avatar asked Aug 05 '13 15:08

ilansch


People also ask

How do you Debug a child process in Visual Studio?

Using the toolOnce you install the power tool from the Visual Studio Gallery, a new menu item will appear on the "Debug" menu under the "Other Debug Targets" sub-menu. When you open the settings page, you'll see a checkbox to enable child process debugging.

How do I start a process in debug mode?

In Visual Studio, from the Tools menu, choose Launch Under Debugger. In the Launch Under Debugger dialog box, enter the path to the executable file. You can also enter arguments and a working directory. Click Launch.

How do I Debug a process in Visual Studio?

You can attach the Visual Studio debugger to a running process on a local or remote computer. After the process is running, select Debug > Attach to Process or press Ctrl+Alt+p in Visual Studio, and use the Attach to Process dialog to attach the debugger to the process.

What is IntelliTrace in Visual Studio?

IntelliTrace always records events that happen in the Visual Studio debugger. For example, starting your application is a debugger event. Other debugger events are stopping events, which cause your application to break execution.


2 Answers

Use the debugger settings Registry key under

HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options

as described in this blog post to make the child process automatically break on startup. Then, when prompted, choose the Visual Studio instance you're using to debug the parent process.

like image 164
Omer Raviv Avatar answered Oct 23 '22 06:10

Omer Raviv


You could try installing the following extension from the Visual Studio team: Introducing the Child Process Debugging Power Tool. It is available on the Gallery for Visual Studio 2013 and above.

It allows automatically attaching child processes to the current debugger, so in your case, the child process started by the WPF app would be attached to the debugger upon launch, and you could therefore easily intercept the main method of the child process.

like image 37
Erwin Mayer Avatar answered Oct 23 '22 05:10

Erwin Mayer