visual-studio 从命令行运行调试模式
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2855586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Run Debug mode from command line
提问by yossharel
I want to run my project in debug mode from the command line, not from Visual Studio (VS is open).
我想从命令行以调试模式运行我的项目,而不是从 Visual Studio(VS 已打开)。
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.
实际上,我想同时初始化我的项目的多个实例(从 bat 文件)并调试它们 - 而不是按多个F5.
采纳答案by sbi
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...
您可以稍后使用工具/附加到进程附加到这些实例...
回答by Dirk Vollmar
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.
要调试应用程序的多个实例,您可以分别从命令行启动它们(或在 VS 中按 Ctrl+F5 启动不附加调试器的应用程序),然后使用Debug -> Attach to Process...手动附加 VS 调试器。菜单命令。
If you want to automatically launch/attach a debugger you could add the following code to your Mainmethod:
如果您想自动启动/附加调试器,您可以将以下代码添加到您的Main方法中:
#if DEBUG
System.Diagnostics.Debugger.Launch();
#endif
This command should display the following dialog which allows you to choose the running instance for debugging:
此命令应显示以下对话框,允许您选择正在运行的实例进行调试:


(i.e. Figure 7 in this article: http://msdn.microsoft.com/en-us/magazine/cc163606.aspx)
(即本文中的图 7:http: //msdn.microsoft.com/en-us/magazine/cc163606.aspx)
回答by Hans Passant
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.
工具 + 附加到进程允许调试多个进程。在“可用进程”列表中,只需单击 + Shift 单击即可选择所有进程。在设置断点时跟踪正在调试的实例应该有点棘手。
回答by Ed Guiness
The .NET Framework SDK includes the command-line runtime debugger named CorDbg.exe
.NET Framework SDK 包括名为CorDbg.exe的命令行运行时调试器

