Skip to content

System.InvalidCastException: Specified cast is not valid #28

Description

@GoogleCodeExporter
System.InvalidCastException: Specified cast is not valid.
   at lambda_method(Closure , Object , Object[] )
   at NConsoler.Consolery.InvokeMethod(MethodInfo method)
   at NConsoler.Consolery.RunAction()
   at NConsoler.Consolery.Run(Type targetType, String[] args, IMessenger messenger, Notation notationType)
   at NConsoler.Consolery.Run(Type targetType, String[] args)
   at MyApplication.Program.Main(String[] args) in C:\MyApplication.Test\Program.cs:line 20

nconsoler 2.0
Windows 7 Ultimate 64-bit SP1
Visual Studio 2010 Premium SP1
.net 4 c# console application

namespace MyApplication.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Consolery.Run(typeof(Program), args);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }

        [Action]
        public static void DoWork(
            [Required(Description="description1")]
            string parameter1,
            [Required(Description="description2")]
            string parameter2,
            [Required(Description="description3")]
            string parameter3,
            [Optional("01-01-2009", Description = "description4")]
            DateTime parameter4,
            [Optional(10, Description = "description5")]
            int parameter5,
            [Optional(@"c:\temp", Description = "description6")]
            string parameter6)
        {
        }
    }
}

MyApplication.Test.exe param1 param2.param2 param3 /param6:"C:\Working"

If I remove the DateTime parameter, it works without issues.

I even tried "1-1-2009" but I get the same exception.

Any ideas?

Thank you.

Original issue reported on code.google.com by rami.abughazaleh@gmail.com on 14 Jan 2012 at 5:04

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions