Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

So there's a program i saw, coded in c#. I keep getting errors on it. System.IndexOutOfRangeException is the main one, its happening at "args[0]". This is the code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace Skype4COMUserProfile
    {
        class Program
        {
            private static SKYPE4COMLib.Skype skype = new SKYPE4COMLib.Skype();

            [STAThread]
            static void Main(string[] args)
            {
                if (!skype.Client.IsRunning)
                {
                    Environment.Exit(1);
                }
                    skype.Client.OpenUserInfoDialog(args[0]);
            }
        }
    }

I will be very grateful if someone could tell me how to fix this. thank you in advance!

share|improve this question
Looks like args is empty. – alex Apr 23 at 20:14

1 Answer

Well that will fail if args is empty. Presumably you're meant to start the program by specifying a user name, or something like that.

You could always check for that:

if (args.Length == 0)
{
    // Show an error dialog here
    return;
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.