Given the following code:
VB Code:
[STAThread] public static void Main(string[] args) { MessageBox.Show("Arguements via args[] = " + args.Length + "\nArguements via Environment.GetCommandLineArgs() = " + Environment.GetCommandLineArgs().Length.ToString()); }
Now I'm a bit confused. I have a large application written with C# and .Net 1.1 (BinaryEdit and I use the string[] args to launch different options. I also don't launch anything unless there is at least 1 arguement (which should be the path of the executable). This works great.
In a new application I'm developing, with C# and .Net 2.0, this code returns 0 for args and 1 for the GetCommandLineArgs(). Why?
An even odder question... I tried to re-create this with 1.1 and C# and if I run this exact code in a new project with 1.1, it returns the same as the 2.0 (0 for the args and 1 for the GetCommandLineArgs()).
So it would appear that this works great for my large application with C# 1.1 but it does not work with any new C# 1.1 projects (windows or console) or my new C# 2.0 project.
Should I be using Environment.GetCommandLineArgs() over passing args to the Main() method? Any insight into my issue?




Reply With Quote