我是Castle Windsor作为我的IoC和TopShelf来运行它作为服务。 当我将它作为控制台应用程序运行时,它运行正常。 何时安装并将其作为服务运行,过了一段时间它就会给我“服务没有响应控制功能”。 仅适用于Windows 8 / Windows Server 2012.它在Windows 7上运行正常。
当我删除BuilContainer()时 ,它在所有平台上都可以正常工作。
我还让我的记录器在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
I am Castle Windsor as my IoC and TopShelf to run it as service. When I'm running it as console app, it works just fine. When is install it and run it as a service, after a while it gives me "The service is not responding to the control function." only on Windows 8/Windows Server 2012. It works just fine on Windows 7.
when I remove BuilContainer(), it works just fine on all platforms.
I also made my logger to log "a0" before BuildContainer and "a1" after that. "a0" will be logged but "a1" won't when running as service.
This approach is used by many including me and it works on Windows 7 but not on 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"); });what is wrong ?
Thanks, Peyman
最满意答案
很可能是某些东西让你的BuildContainer()花了太长时间而且服务经理说,“呃,你太慢了”。 将应用程序作为控制台运行时没有时间限制。 我不确定Windows版本之间的时间限制是否发生变化,以说明为什么它只会在Win8 / 2012上出错。 这些机器上的东西也可能使BuildContainer()比旧系统花费更长的时间。
假设我是对的,你怎么解决它? 如果不了解你在容器中做了什么,很难说。 这看起来几乎与我的Topshelf服务看起来一样,所以你至少在正确的轨道上。 也许你可以在容器中推迟一些事情,直到以后?
Most likely something is making your BuildContainer() take too long and the service manager is saying, "eh, you too slow". There's no time limits when running the app as a console. I'm not sure if the time limits changed between Windows versions to say why it's only errorring on Win8/2012. It's also possible something on those machines make BuildContainer() take longer than on older systems.
Assuming that I'm correct, how do you fix it? It's hard to say without understanding what you're doing in your container. This looks almost exactly like what my Topshelf services look like, so you're on the right track at least. Maybe there's something you can defer doing in your container until later?
更多推荐
发布评论