TopShelf服务安装无法正常工作

时间:2020-05-10 17:15:57

标签: c# .net windows installation topshelf

我已经构建了此Windows服务,并确保可以在本地使用。现在,尽管TopShelf的“ ServiceName install”命令的输出表明安装成功,但找不到该服务。

这是我的服务配置代码:

HostFactory.Run(servConfig => 
             {
                servConfig.Service<TimerService>(servInst => 
                {
                    servInst.ConstructUsing(
                        () => new TimerService());

                    servInst.WhenStarted(execute => execute.Start());
                    servInst.WhenStopped(execute => execute.Stop());
                });

                servConfig.SetServiceName("StayActiveService");
                servConfig.SetDisplayName("Stay active service");
                servConfig.SetDescription("Automatic timer setter");

                servConfig.StartAutomatically();
             });

2 个答案:

答案 0 :(得分:0)

您可以添加此行并尝试:

servConfig.RunAsLocalSystem();

答案 1 :(得分:0)

经过一些尝试,它神奇地修复了自己,但是绝对有一个权限警告窗口事件日志与“ LocalSystem”有关,因此your的建议可能也有帮助。

相关问题