Run Debug mode from command line

2020-02-05 17:40发布

I want to run my project in debug mode from the command line, not from Visual Studio (VS is open).

Is there any parameter to add to the command?

Actually, I want to initialize multiple instances of my project at the same time (from bat file) and debug them - instead of pressing multiple F5.

4条回答
Rolldiameter
2楼-- · 2020-02-05 17:58

You can start your executables from the command line by just typing their (path and) name.

You can later attach to those instances using Tools/Attach to Process...

查看更多
The star\"
3楼-- · 2020-02-05 17:58

For debugging multiple instances of your application you can launch them separately from the command line (or press Ctrl+F5 in VS to launch the application without debugger attached) and then attach the VS debugger manually using the Debug -> Attach to Process... menu command.

If you want to automatically launch/attach a debugger you could add the following code to your Main method:

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

This command should display the following dialog which allows you to choose the running instance for debugging:

Visual Studio Just-In-Time-Debugger

(i.e. Figure 7 in this article: http://msdn.microsoft.com/en-us/magazine/cc163606.aspx)

查看更多
孤傲高冷的网名
4楼-- · 2020-02-05 18:07

Tools + Attach to Process allows debugging multiple processes. In the "Available Processes" list just click + Shift click to select all of them. Keeping track of which instance you're debugging when you set a breakpoint ought to be a bit tricky.

查看更多
啃猪蹄的小仙女
5楼-- · 2020-02-05 18:16

The .NET Framework SDK includes the command-line runtime debugger named CorDbg.exe

查看更多
登录 后发表回答