Solved

Why does my 1st command line argument show up as a path to vshost.exe?

Posted on 2014-03-28
4
591 Views
Last Modified: 2014-03-28
I'm building a desktop application in VS 2012 C#. While testing the applcation, I'm reading in commmand line arguments that i've set in the debug section of the application properties. I've only set 4 values (each separated by a space). However, when, in my code I attempt to access args[0], it is not the first argument that i've put in, its the path on my machine that leads to the vshost.exe file in the debug directory of my application file structure. Why is this and how do I prevent this from happening? I really want my 1st argument to be what I have typed into the debug section of the application properties.
0
Comment
Question by:mikesExpertExchange
  • 2
  • 2
4 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 39962535
Hi mikesExpertExchange;

The command line arguments array, args[0], will always show the executing program as the first element. This is the way it was implemented in the language. all other elements start at index 1 of the array. This can not be changed.
0
 
LVL 1

Author Comment

by:mikesExpertExchange
ID: 39962545
Ok. I was just wondering. In a much older VB version of my app. (I'm rewriting it in C#) there first arg is actually what they've typed into the command line arguments in the debug properties of the app, so I was just curious as to why mine wasn't. Which version of VS did they make this a rule in? Just curious. If I can't change it then I can't change it. And in a sense, that makes it easy / an easier solution.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 39962603
This was always the case in C# and I believe in VB .Net. Were you using a Visual Basic pre .Net version where I believe it worked as you stated.
0
 
LVL 1

Author Closing Comment

by:mikesExpertExchange
ID: 39962809
thanks
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Offline Apllication 5 51
Server Error 11 47
ASP.net Javascript use multiple sliders 2 16
VB.NET Repostiory Pattern 7 0
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now