Why isn't argument passed in?

Posted on 2007-03-30
Last Modified: 2010-04-16
I have a winform app and set a conditional compilation symbol for the project.  In the Program.cs file, I do this:

static void Main(string[] args )

but there is never anything in the args variable.  Do I need to do something else?
Question by:brettr
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 18823761
the args is what you pass from the command line to the program.
do you pass anything to the program?

Author Comment

ID: 18823797
In the project properties for conditional compilation symbols, I specify a string.
LVL 25

Expert Comment

ID: 18823935
Those don't go to the args.  If you want to pass in arguments from studio, add them to the "Command Line Arguments" under the Debug tab
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now


Author Comment

ID: 18824078
Arg!  You're absolutely right.  These are only available when compiling in debug right?
LVL 25

Expert Comment

ID: 18824098
No.  you can use different settings when building debug vs release modes, though.  They are used whenever you start the app from within studio (with or without debugging)

Author Comment

ID: 18824351
If I compile in release, it doesn't capture the argument.  Only when compiled in debug.
LVL 25

Accepted Solution

dstanley9 earned 500 total points
ID: 18824378
Whan looking at the project properties, change the "Configuration" drop-down to Release and set the arguments there.  If you added the args in the Debug configuration, it doesn't automatically copy to other configurations. You can change the drop-down to "All" to set the same value in all configurations.

Author Comment

ID: 18824460
I see.  Thanks.

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how to remove duplicate code from my project 5 66
c# ftp code 3 56
How do I "share" on social sites? 2 39
What is GIS method of Geometry data type? 6 36
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question