How to debug a C# command-line program

后端 未结 6 1659
说谎
说谎 2021-02-07 04:11

I\'m trying to build a command-line tool in C# with VS2010.

My question is: how do I debug this, like I would a winforms.
With winforms, I can step through the code,

6条回答
  •  既然无缘
    2021-02-07 04:30

    You can use Visual Studio to attach a debugger to the command line application, once it is under way with the correct arguments. I'm not sure if your application will terminate quickly or give you any opportunity to attach the debugger, but if it will, this should work.

    I'm using VS2008 but I'll bet the process is similar in 2010:

    1. In VS, go to Tools and click Attach to Process
    2. Choose your application from the list and press Attach

    Now VS should be able to finagle its way into your application and break on an error.

提交回复
热议问题