Top Shelf giving an error Sequence contains more than one element
I am trying to host a console application as window service using top shelf here is the code :
RunConfiguration cfg = RunnerConfigurator.New(x =>
{
x.ConfigureService<Certegy>(s =>
{
s.Named("certegy");
s.HowToBuildService(name => new Certegy());
s.WhenStarted(tc => tc.Start());
s.WhenStopped(tc => tc.Stop());
});
if (string.IsNullOrEmpty(args[1]开发者_如何学C))
{
x.RunAsLocalSystem();
}
else
{
x.RunAs(args[1], args[2]);
}
x.SetDescription("Certegy host to get the messages from the queue");
x.SetDisplayName("Certegy Interface");
x.SetServiceName("Certegy Interface");
});
Runner.Host(cfg, args);
From command line i am running as :
ExeName install username password
I am getting an error {"Sequence contains more than one element"}
in last line
Runner.Host(cfg, args);
Can someone please help ?
What version of Topshelf are you using?
The username and password via the command line has not been working in a while, if you grab the latest development code from Chris, who added this feature, at https://github.com/phatboyg/Topshelf/tree/develop I think it has been addressed, otherwise just set it in the code to read from an app.config for the time being.
精彩评论