How to start another process in debug mode?

I am writing a windows service. This service starts another process that I developed using the methods of the Process class, but I also want to start this process in debug mode, for example, using breakpoints.

How can i do this?

+3
source share
3 answers

When debugging, the DebugBreak () service is very nice. You can even debug the start of the service, which can be very difficult if you try to attach the process.

In c #

#if DEBUG
  System.Diagnostics.Debugger.Break();
#endif

In c ++

#if DEBUG
  System.Diagnostics.Debugger.Break();
#endif

Also see the question: how to use debugbreak () in C #.

+4
source

In the main menu, "Debug-> Attach Process".

+2
source

As in the "attach process" mode, it was sometimes convenient for me to have an executable file that can be run directly from Visual Studio (or as a console application). I can’t remember if there were any difficulties with this, but I don’t think it was ... you just need to provide a normal entry point as well as a service entry point.

+1
source

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


All Articles