How to debug a C# command-line program

后端 未结 6 1662
说谎
说谎 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:36

    You could add a call to Debugger.Launch to your startup code. Then you can compile, and start your app from the command line. You'll get a prompt asking you which debugger you want to attach (typically this will be a list of the different versions of Visual Studio you have installed), and away you go.

    (But really, setting command-line parameters in Project properties > Debug tab is the better way to go most of the time. If that's not working for you, you should figure out why.)

提交回复
热议问题