【发布时间】:2011-01-17 08:50:14
【问题描述】:
更新 2:
似乎这个库根本不支持 Compact-Framework,而且我不断收到其他异常 - 我将这个问题保持原样,但我认为你不应该浪费时间回答它。
我opened another question 建议其他紧凑框架友好的库。
使用Command Line Parser Library。
我正在使用以下代码来定义命令行参数:
[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;
}
我在help.AddOptions(this) 上收到 TargetInvocationException。跟踪是:
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)
如果需要其他的请评论,我会发布。
我在MethodInfo 的文档中找不到它引发了这个异常,所以我不明白为什么我会得到它。 我以与库示例相同的方式使用它,并且在示例应用程序中没有出现异常。
我想原因在于我正在为智能设备编译它。可能与 CF3.5 的支持有关,但我不确定。
使用 VS2008。
更新: 我应该提到该示例在完整框架上运行,而我的应用程序在紧凑版本上运行。
我注意到 CF3.5 中的 MethodInfo 没有 ReturnParameter 属性,而不是完整的框架版本。
同样作为InnerException 下方答案的答案,MissingMethodException
谢谢。
【问题讨论】:
标签: c# .net-3.5 compact-framework