Command line arguments count is different in debugger?

Hello,

I am working with a command line application targeting the Island / Windows platform.

public static Int32 Main(string[] args)
{
        Console.WriteLine(string.Format("Arguments: {0}\n", args.Length));

        // Validate the parameters
        if (args.Length != 2) {
            Console.WriteLine("usage: telnet server port\n");
            return 1;
        }
}

I have two arguments specified in the project options: 127.0.0.1 and 2101

When I run this in the debugger it reports 2 arguments and when I run it from the command line it reports three. The difference being that running it from the command line passes the exe file name as argument 0 and the debugger does not.

Shouldn’t the debugger pass the exe file name as argument 0?

Brian

Not sure, which behavior is more desirable (with or w/o exe as first param), as the different platforms handle this differently, and ideally we should consulate this somehow so that it’s consistent for Elements everywhere. But it either case, we need to make it consistent between debugger and non/debugger, of course.

Thanks, logged as bugs://80302

bugs://80302 got closed with status fixed.

Yeah the debugger should pass the exe as the first argument (And doesn’t). Additionally the windows entry point should NOT pass the first arg to args. Fixed both (not sure if it makes it for fridays build though; it’s part of our new debugging infrastructure)

I don’t understand what you mean by:

It should NOT have the exe file name as [0].

It sounds like you’re saying that the debugger should pass the exe name as the argument [0]…

…and the command line should not pass the exe name as argument [0]:

That doesn’t make any sense and would appear to be exactly the opposite of what it’s doing now (unless I’m missing something). Whatever you do it should be consistent. The first argument passed on the command line should be in the same position in the list of arguments regardless of where it’s run.

Just for comparison’s sake I tried creating a simple console application in Microsoft’s C# and specified two arguments, an IP address and port number.

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i=0; i<args.Length; i++)
            {
                Console.WriteLine(args[i]);
            }

            Console.WriteLine("Done!");
        }
    }
}

In both cases I get exactly the same output:

127.0.0.1
6001
Done!

Yeah. I just fixed that … It should match what MS C# does.