当我温莎城堡作为我的IoC和TopShelf运行它的服务。 当我运行它作为控制台应用程序,它工作得很好。当是时它给我安装并运行它作为一种服务,经过“服务没有响应控制功能。”仅在Windows 8/Windows的Server 2012的时候我删除BuilContainer(),它只是罚款在所有平台上它在Windows 7“服务没有响应控制功能”?使用IoC的
就好了。
我还做了我的记录器记录BuildContainer之前“A0”和之后的“A1”。 “a0”将被记录,但在作为服务运行时,“a1”不会被记录。
这种方法被很多,包括我和它适用于Windows 7,但无法在Windows 8/Windows Server 2012中
BuildContainer(); // builds IWindsorContainer and registers component.
HostFactory.Run(x =>
{
x.Service<IService>(config =>
{
config.ConstructUsing(o => Container.Resolve<IService>("myService"));
config.WhenStarted(o => o.Start());
config.WhenStopped(o => {o.Stop(); Container.Dispose();});
});
x.RunAsLocalSystem();
x.SetServiceName("ServiceName");
x.SetDescription("ServiceDesc");
x.SetDisplayName("ServiceDispName");
});
有什么不好?
感谢, Peyman的
我要求额外的时间和问题解决,但我更喜欢不这样做,而是我在服务启动后执行此任务。 – Peyman
很高兴你有一个解决方案,然后。祝你好运! – Travis