Whilst running a C# console application in debug mode, is it possible to start another C# console application, (either the same program or different program), using with Process.Start(), and then attach it to the debugger automatically with C# source code?
I am using Visual Studio 2017+, .NET 4.7.2, C# 7.3.
This question is not a duplicate because none of the suggested questions/answers fully answer this specific question. I am looking for a fully automated way to attach any process object to the current debugger using source code. None of the answers in the other questions specifically address this. For example, they suggest outdated addins, spawning a new debugger instance, or manually attaching the process, rather than achieving the task with C# source code.
For example:
var this_exe = Environment.GetCommandLineArgs()[0];
var p = Process.Start(this_exe, "/compute");
// How to attach 'p' to the debugger?