0

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?
0

1 Answer 1

1

In Main method of exe that you are starting with Process, add Debugger.Launch(), like

private static void Main(string[] args)
{
    Debugger.Launch();
    //your code
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.