Topshelf例外 [英] Topshelf exception
本文介绍了Topshelf例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用 topshelf ,当我尝试使用-i我得到这个例外选项来安装为服务......请帮我..
无法转换类型'Magnum.CommandLineParser.SwitchElement'的对象键入Magnum.CommandLineParser.IArgumentElement。
块引用>
例外发生在这个函数
静态无效集(TopshelfArguments ARGS,
的IEnumerable< ICommandLineElement> commandLineElements)
{
VAR命令= commandLineElements
。取(1 )
。选择(X =>(IArgumentElement)X)// EXCEPTION BREAKS在这条线
。选择(X => x.Id)
.DefaultIfEmpty(命令行)
.SingleOrDefault();
args.Command =命令;
//剩菜
args.CommandArgs = commandLineElements.Skip(1).ToList();
}
感谢
解决方案我们使用TopShelf安装为服务
的Program.exe服务安装方式
我相信这是它的遥控代码的支持的唯一途径。您可以通过
的Program.exe服务卸载
I'm using topshelf and I'm getting this exception when I try to use the "-i" option to install as a service...please help me..
Unable to cast object of type 'Magnum.CommandLineParser.SwitchElement' to type 'Magnum.CommandLineParser.IArgumentElement'.
Exception occurs in this function
static void Set(TopshelfArguments args, IEnumerable<ICommandLineElement> commandLineElements) { var command = commandLineElements .Take(1) .Select(x => (IArgumentElement) x) //EXCEPTION BREAKS ON THIS LINE .Select(x => x.Id) .DefaultIfEmpty("commandline") .SingleOrDefault(); args.Command = command; //leftovers args.CommandArgs = commandLineElements.Skip(1).ToList(); }
Thanks
解决方案The way we use TopShelf to install as a service is
program.exe service install
I believe this is the only way it's supported in the RC code. You can uninstall via
program.exe service uninstall
这篇关于Topshelf例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文