Question

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

Was it helpful?

Solution

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top