“服务没有响应控制功能”?(“Service is not responding to control function”? when using IoC)

编程入门 行业动态 更新时间:2024-10-24 12:31:24
“服务没有响应控制功能”?(“Service is not responding to control function”? when using IoC)

我是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?

更多推荐

本文发布于:2023-08-07 00:45:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457826.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:功能   Service   responding   IoC   function

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!