35

I am writing a Console application that pass a string array of arguments to the Main. Using the F5 to debug would throw me an exception because I have not pass the arguments.

The way I debug/test the code where I can pass arguments is to build the solution and then run the .exe on the command prompt, but it's very inconvenient.

Is there a way to pass arguments to debug?

horns
  • 1,843
  • 1
  • 19
  • 26
KMC
  • 19,548
  • 58
  • 164
  • 253
  • 2
    I think you'll find your answer here http://stackoverflow.com/questions/6475887/passing-command-line-parameters-with-vs-2010-c-sharp – Mithrandir Feb 28 '12 at 08:31

4 Answers4

53

From within Visual Studio? Absolutely - go to the project's property designer, select the Debug page and you can set the command line arguments, as well as the working directory. See MSDN for more information.

Joseph Woodward
  • 9,191
  • 5
  • 44
  • 63
Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
24

In Visual Studio right-click on the project name in Solution Explorer. Select Properties from the list. Go to the Debug tab. You can put your parameters in Command Line Arguments textbox.

Adam Pope
  • 3,234
  • 23
  • 32
1

This page has documentation on C# debugging. Basically, there is a "command line arguments" option in the project's property pages.

Ken Wayne VanderLinde
  • 18,915
  • 3
  • 47
  • 72
1

You should be able to enter command line arguments in the Project Settings dialog.

There's some info here: http://msdn.microsoft.com/en-us/library/2kf0yb05.aspx

Jon Egerton
  • 40,401
  • 11
  • 97
  • 129