顶层给出错误序列包含多个元素

发布于 2024-10-18 09:20:31 字数 899 浏览 2 评论 0原文

我正在尝试使用顶层架子将控制台应用程序托管为窗口服务,这里是代码:

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]))
    {
        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);

从命令行我运行为:

ExeName install username password 

我收到错误 {"Sequence contains more more element"} in最后一行

Runner.Host(cfg, args);

有人可以帮忙吗?

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]))
    {
        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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

穿透光 2024-10-25 09:20:31

您使用的是哪个版本的 Topshelf?

通过命令行的用户名和密码已经有一段时间无法使用了,如果您从 Chris 那里获取了最新的开发代码,他添加了此功能,位于 https://github.com/phatboyg/Topshelf/tree/develop 我认为它已经得到解决,否则只需将其设置在代码中以从 app.config 读取暂时。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文