TopShelf [失败] 停止不能为空
TopShelf [Failure] Stop must not be null
Topshelf v3.2.150.0 .Net Framework v4.0.
安装服务失败;
Topshelf.HostFactory Information: 0 : Configuration Result:
[Success] Name ZipPack
[Success] Description 9 Angle Zip Refresh
[Success] ServiceName ZipPack
Topshelf.HostConfigurators.HostConfiguratorImpl Information: 0 : Topshelf v3.2.150.0, .NET Framework v4.0.30319.42000
Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshelf.HostConfigurationException: The service was not properly configured:
[Failure] Stop must not be null
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results)
at Topshelf.ServiceExtensions.<>c__DisplayClasse`1.<CreateServiceBuilderFactory>b__d(HostSettings x)
at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
at Topshelf.HostFactory.New(Action`1 configureCallback)
Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.HostConfigurationException: The service was not properly configured:
[Failure] Stop must not be null
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results)
at Topshelf.ServiceExtensions.<>c__DisplayClasse`1.<CreateServiceBuilderFactory>b__d(HostSettings x)
at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
at Topshelf.HostFactory.New(Action`1 configureCallback)
at Topshelf.HostFactory.Run(Action`1 configureCallback)
Program.cs 看起来像这样;
public static class Program
{
public static void Main(string[] args)
{
HostFactory.Run(x =>
{
x.Service<ZipPackService>(s =>
{
s.ConstructUsing(name => new ZipPackService(new ServiceRepository(new FileHelper())));
s.WhenStarted((tc, hostControl) => tc.Start(hostControl));
s.WhenStarted((tc, hostControl) => tc.Stop(hostControl));
});
x.RunAsLocalSystem();
x.StartAutomaticallyDelayed();
x.SetDescription("9 Angle Zip Refresh");
x.SetDisplayName("ZipPack");
x.SetServiceName("ZipPack");
});
}
}
这是一个命令行程序,正在转换为 运行 作为服务。按照 Main() 中入口点的 topshelf 手册示例。尝试过搜索引擎,但他们只返回来自 Git 的错误消息来源。服务继承自ServiceControl。
在服务中,Start() 方法已定义为;
public bool Start(HostControl hostControl)
{
PollProcess();
return true;
}
PollProcess() 使用 windows 事件触发器来检测添加到目录中的文件。
缺少什么配置?
你有两个 whenStarted when 最后一个应该是 whenStopped
即
public static void Main(string[] args)
{
HostFactory.Run(x =>
{
x.Service<ZipPackService>(s =>
{
s.ConstructUsing(name => new ZipPackService(new ServiceRepository(new FileHelper())));
s.WhenStarted((tc, hostControl) => tc.Start(hostControl));
s.WhenStopped((tc, hostControl) => tc.Stop(hostControl));
});
x.RunAsLocalSystem();
x.StartAutomaticallyDelayed();
x.SetDescription("9 Angle Zip Refresh");
x.SetDisplayName("ZipPack");
x.SetServiceName("ZipPack");
});
}
Topshelf v3.2.150.0 .Net Framework v4.0.
安装服务失败;
Topshelf.HostFactory Information: 0 : Configuration Result:
[Success] Name ZipPack
[Success] Description 9 Angle Zip Refresh
[Success] ServiceName ZipPack
Topshelf.HostConfigurators.HostConfiguratorImpl Information: 0 : Topshelf v3.2.150.0, .NET Framework v4.0.30319.42000
Topshelf.HostFactory Error: 0 : An exception occurred creating the host, Topshelf.HostConfigurationException: The service was not properly configured:
[Failure] Stop must not be null
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results)
at Topshelf.ServiceExtensions.<>c__DisplayClasse`1.<CreateServiceBuilderFactory>b__d(HostSettings x)
at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
at Topshelf.HostFactory.New(Action`1 configureCallback)
Topshelf.HostFactory Error: 0 : The service terminated abnormally, Topshelf.HostConfigurationException: The service was not properly configured:
[Failure] Stop must not be null
at Topshelf.Configurators.ValidateConfigurationResult.CompileResults(IEnumerable`1 results)
at Topshelf.ServiceExtensions.<>c__DisplayClasse`1.<CreateServiceBuilderFactory>b__d(HostSettings x)
at Topshelf.HostConfigurators.HostConfiguratorImpl.CreateHost()
at Topshelf.HostFactory.New(Action`1 configureCallback)
at Topshelf.HostFactory.Run(Action`1 configureCallback)
Program.cs 看起来像这样;
public static class Program
{
public static void Main(string[] args)
{
HostFactory.Run(x =>
{
x.Service<ZipPackService>(s =>
{
s.ConstructUsing(name => new ZipPackService(new ServiceRepository(new FileHelper())));
s.WhenStarted((tc, hostControl) => tc.Start(hostControl));
s.WhenStarted((tc, hostControl) => tc.Stop(hostControl));
});
x.RunAsLocalSystem();
x.StartAutomaticallyDelayed();
x.SetDescription("9 Angle Zip Refresh");
x.SetDisplayName("ZipPack");
x.SetServiceName("ZipPack");
});
}
}
这是一个命令行程序,正在转换为 运行 作为服务。按照 Main() 中入口点的 topshelf 手册示例。尝试过搜索引擎,但他们只返回来自 Git 的错误消息来源。服务继承自ServiceControl。
在服务中,Start() 方法已定义为;
public bool Start(HostControl hostControl)
{
PollProcess();
return true;
}
PollProcess() 使用 windows 事件触发器来检测添加到目录中的文件。
缺少什么配置?
你有两个 whenStarted when 最后一个应该是 whenStopped
即
public static void Main(string[] args)
{
HostFactory.Run(x =>
{
x.Service<ZipPackService>(s =>
{
s.ConstructUsing(name => new ZipPackService(new ServiceRepository(new FileHelper())));
s.WhenStarted((tc, hostControl) => tc.Start(hostControl));
s.WhenStopped((tc, hostControl) => tc.Stop(hostControl));
});
x.RunAsLocalSystem();
x.StartAutomaticallyDelayed();
x.SetDescription("9 Angle Zip Refresh");
x.SetDisplayName("ZipPack");
x.SetServiceName("ZipPack");
});
}