Can not debug a Project started using Process.Start()

前端 未结 5 1304
青春惊慌失措
青春惊慌失措 2021-01-02 02:49

I have two C# WinForm projects in the same solution lets call them A and B. Project A starts Process B via a call like below

ProcessStartInfo psi = new Proce         


        
5条回答
  •  甜味超标
    2021-01-02 03:03

    In the 2nd project have it check its command line arguments, if it sees something like --debug was passed in as the first argument the 2nd program launches the debugger itself

    private static void Main(string[] args)
    {
        //If no debugger is attached and the argument --debug was passed launch the debugger
        if (args.Length == 1 && args[0] == "--debug" && Debugger.IsAttached == false)
            Debugger.Launch();
    
        //(snip) the rest of your program
    
    }
    

    When you do this you will get a dialog window that will allow you to choose to open a new copy of Visual Studio or just use your already open copy.

    image


    You can also put the child process in the Image File Execution Options registry key.

提交回复
热议问题