.net - 如何配置 TopShelf 以作为 ServiceAccount.NetworkService 运行服务?

标签 .net windows-services topshelf

如何配置 TopShelf 以作为 ServiceAccount.NetworkService 运行服务?

https://github.com/Topshelf/Topshelf

最佳答案

TopShelf 的新位置,http://github.com/Topshelf/Topshelf , 已经更新了一个允许这种行为的补丁。

RunConfiguration cfg = RunnerConfigurator.New(x =>
{
    x.AfterStoppingTheHost(h => { Console.WriteLine("AfterStop called invoked, services are stopping"); });

    x.ConfigureService<TownCrier>(s =>
    {
        s.Named("tc");
        s.HowToBuildService(name=> new TownCrier());
        s.WhenStarted(tc => tc.Start());
        s.WhenStopped(tc => tc.Stop());
    });
    // Running as the network service account
    x.RunAsNetworkService();

    x.SetDescription("Sample Topshelf Host");
    x.SetDisplayName("Stuff");
    x.SetServiceName("stuff");
});

Runner.Host(cfg, args);

关于.net - 如何配置 TopShelf 以作为 ServiceAccount.NetworkService 运行服务?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3244120/

相关文章:

psexec - 无法使用 psexec 远程运行 TopShelf 安装

.net - Topshelf超时问题

.net - HostFactory.Run和HostFactory.New有什么区别

c# - FileStream WriteAsync 和 await 混淆

c# - 为什么在构造函数中实例化新对象之前检查类变量是否为空?

java - 使用 IKVM.Net 将 Apache POI .jar 转换为 .dll

c# - System.Threading.Timer 不触发我的 TimerCallBack 委托(delegate)

c# - 无法从程序集中加载 "FindRibbons"任务

c# - 在 Windows 服务 C# 中引发自定义类事件

windows - 在 Windows 服务模式下运行 GUI 应用程序