views:

144

answers:

2

Update 2: Seems that this library is not Compact-Framework aware at all and I keep getting other exceptions - I am leaving this question as is, but I think you should not waste time on answering it.
I opened another question for suggestion of other compact-framework friendly libraries.


Using the Command Line Parser Library.

I am using the following code to define the command line arguments:

[Option("d", "duration", Required = true,  HelpText = "text.")]
public int duration = DEFAULT_TEST_DURATION;

[Option("s", "sleeptime", HelpText = "text.")]
public int sleepTime = DEFAULT_TEST_SLEEP;

[Option("p", "pause", HelpText = "text.")]
public int iterInterval = DEFAULT_TEST_INTERVAL;

[Option(null, "nosync", HelpText = "text.")]
public bool nosync = false;

[Option(null, "nosuspend", HelpText = "text.")]
public bool nosuspend = false;

[Option(null, "reboot", HelpText = "text.")]
public bool reboot = false;

[HelpOption(HelpText = "Dispaly this help screen.")]
public string GetUsage()
{
    HelpText help = new HelpText("MyExe");
    help.AddPreOptionsLine("Usage: MyExe -d 500 -s 20 -p 10 --nosync");
    help.AdditionalNewLineAfterOption = true;
    help.AddOptions(this);
    return help;
}

I am getting TargetInvocationException on help.AddOptions(this). The trace is:

System.Reflection.TargetInvocationException was unhandled
  Message="TargetInvocationException"
  StackTrace:
       at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)

If the rest is needed please comment and I will post it.

I could not find in the documentation for MethodInfo that it throws this exception and so I can't see why I am getting it. I use this the same way the sample of the library does and I don't get an exception in the sample application.

I guess that the reason lies in the fact that I am compiling this for a smart device. Probably has to do with support in the CF3.5, but I am not sure.

Using VS2008.

Update: I should have mentioned that the sample runs on the full framework whereas my app runs on the compact version.

I noticed that MethodInfo in CF3.5 does not have a ReturnParameter property as opposed to the full framework version.

Also as an answer to the answer below the InnerException gives MissingMethodException

Thanks.

+1  A: 

The InnerException property should give you more details:

try{
    help.AddOptions(this);
} catch (TargetInvocationException e) {
    Console.WriteLine(e.InnerException);
}

P.S: You are using this library, right?

Paolo Tedesco
Yes, I updated the question with a link to the library.
Shaihi
I am getting System.MissingMethodException.I noticed using the debugger that in the CF version `MethodInfo` does not have a ReturnParameter property. I guess that is the source of the problem.
Shaihi
If it's CF-specific I cannot help, sorry...
Paolo Tedesco
Thanks anyhow...
Shaihi
You're welcome... if it's you who up-voted my answer, then you'd better remove the vote, so when people search for unanswered questions yours will pop out (and maybe someone else will be able to provide you real help) :)
Paolo Tedesco
Too late. Besides it was helpful so you deserve it.
Shaihi
A: 

the library is not designed for the Compact-Framework

Shaihi