How to debug a process launched from a debugged process - visual-studio

I'm developing a launcher application (WinForms, C#). This means that I have three project, let's call them A, B, and Launcher; Launcher has two buttons to start A and B respectively. It does so via Process.Start, effectively launching the exe's as a new process.
My problem is that when I run Launcher in the debugger, if I click A, a new process of A is launched, but it is not attached to the debugger.
I know I can attach it at any time, but what I ask is: is there a way to "auto-attach" the process that is launched from a process that is being debugged?

Related

Explanation of attach to process in PyCharm?

What is going on in the background in PyCharm whenever you run these PyCharm instructions to "attach to a local process", that makes it possible to then set breakpoints and debug. (A Chalice/Flask app lets say...)
Often the PyCharm debugger pydev.py will be launched first and spawn the process that runs the code you want to debug.
When an application/process is launched separately "Attach to Process" means the debugger process will be launched in parallel and be attached to an already running process that the debugger did not spawn (like Chalice/Flask or other applications that use their own spawning process).

How can I debug a process started from another process?

I have a hub application that is responsible for handling the launching of three other programs. I am having considerable difficulty with this - When I launch one of the three alone, everything is fine; when I try to run them from the main hub application, they crash.
I need to figure out how I can keep the hub open, and open the process I start with the debugger after it launches right off, so I can catch the issues and debug it properly.
To give an example for how I am starting the processes from the main program -
this.Hide( );
Process.Start( FilePath).WaitForExit( );
Process.GetCurrentProcess( ).Kill( );
Visual Studio has a setup that allows it to debug any application that crashes before calling ExitProcess() and in case the process threw an exception, if the exception is not caught (i.e. try + catch(...) + exit(1)).
I always let the installer turn on that feature, but if you have it turned off, you should be able to turn it back on by going in the settings. Once one, on a crash, you get a message box asking you whether you want to debug the crashing process.

How to capture exiting of Qt Application when shut down by debugger?

I am developing a GUI application in Qt 4.8.4 with Visual Studio 2010. I need to perform some cleanup work before my application closes so I have reimplemented the QWidget closeEvent in my MainWindow class to capture when the user either clicks X or when they select File->Exit from the menu. That works fine. The problem however is when I am running the application in the VS debugger and I use the debugger to shut down the application the close event doesn't get triggered. I can always just shutdown my application by clicking File->Exit or clicking X but sometimes I forget and shut down the debugger instead so it's really more of an annoyance. Is there a way to capture when the debugger shuts down my application?
Not that I know of.
The logic of it: the debugger is running a sandbox, and when it shuts down, the sandbox gets freed. Your application is running inside that sandbox - so when that sandbox gets freed/closed/destroyed, your app simply vanishes without any cleanup.

MSMQ Trigger opens executable as background process

I'm using a Microsoft Message Queuing (MSMQ) Trigger to launch a standalone executable on Windows 8.1. The exe was not launching so I tried opening Notepad instead (thanks John). That did not work either so I peaked at the Task Manager and noticed that it was opening as a Background Process.
My question is: why does the application open as a background process and how do I prevent this?
Is it possible to add a launch Parameter, for example?
Edit
I should note that I'm okay with the exe running in the background once my application goes live. I would like to prevent it from doing so during development, however.

windows ce application opening and closing

I have a program in Windows CE 5.0 created in Visual Studio 2008. Opening the application I created works fine but when I close the application with:
Application.Exit()
I cannot open another application, I cannot even open the same application again.
Any idea what about closing the program properly? I have also tried using
Me.Close()
or
Environment.Exit()
cannot open another application, I cannot even open the same application again.
Looks like your application does not exit and 'blocks' the GUI. Or what exactly does the above mean? Can click the start button and a menu opens?
If your app uses background thread, the app will not close correctly until these threads are terminated too. You will have the app still in the process list but no GUI, the app seem to have terminated but it did not.
If you have background threads you have to terminate them BEFORE you Exit the application.
Background threads can be terminated using Thread.Abort() or using a condition in a while loop. For the thread.avort you have to code the lines of the background thread within a try/Catch block and catch for the ThreadAbortException.

Resources