Any success with this yet? If not, I hope this will help you (sorry for answering so late!).
Do you try to start the Alerter service "manually" with ServiceController.Start class? You should avoid doing this. Instead, on installation time set your service to have a dependency on the Alerter service. Now the Windows SCM should start the Alerter service for you automaticly. (You can set the dependency manually using the Service MMC in administrative tools (or using the sc.exe tool in Windows XP and newer systems)). See the remarks for the ControlService API to see why: "The SCM processes service control notifications in a serial fashion � it will wait for one service to complete processing a service control notification before sending the next one. Because of this, a call to ControlService will block for 30 seconds if any service is busy handling a control code. If the busy service still has not returned from its handler function when the timeout expires, ControlService fails with ERROR_SERVICE_REQUEST_TIMEOUT."[1] You may also try to make sure that you respond to the SCM first that you've handled the control(custom command) and then start the service. But in general a dependency would be better to use. But as Mark wrote, you should avoid doing SCM calls from a service. On a project I worked on in the past we had a requirement which made it difficult to use service dependencies, so we had to start the dependent services ourself. We started with using custom commands, but after a while figured out that a separate control protocol for this is much better. This removes (most) of the restrictions on doing SCM calls from a service (except that you can't call SCM APIs during initialization of your service(and maybe some other? Be always careful when dealing with the SCM :))). So, my experience is that the "service commands" and the "functional commands" a service needs to handle should be separate sets of commands. For example, you have start, pause and stop commands for controlling the service, but you can also have the same commands for the service's functionality (like starting, pausing and stopping a session the service controls. But the service should still be running even when the session is paused, so therefore you get two different command sets.). Again, hope this helps! Regards, Andreas H�ber [1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas e/controlservice.asp?frame=true (See "Remarks" section) PS: Seems like the information in [1] above is not documented in the .NET SDK. But since the classes in the System.ServiceProcess namespace uses the Win32 APIs, everything in the docs about the Win32 APIs applies to the .NET SDK. And it seems like the documentation for the .NET classes misses a lot of the information from the Win32 APIs (at least what I could find on msdn.microsoft.com/library at the moment). > -----Original Message----- > From: Unmoderated discussion of advanced .NET topics. [mailto:ADVANCED- > [EMAIL PROTECTED] On Behalf Of Eric Means > Sent: Saturday, December 04, 2004 12:50 AM > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] ServiceControlManager within an NT Service > > Robert, I've written several Windows Services that use the SCM classes > to control other services. I would check the Event Log to see if the > Alerter service is logging anything. Also check to see if there's an > InnerException or explanation in the exception the SCM is throwing. > > > On Fri, 3 Dec 2004 15:55:51 +1100, Robert Rolls > <[EMAIL PROTECTED]> wrote: > > I have an NT service that is calling ServiceControlManager from within a > > custom command. The problem however is that it times out for the Alerter > > service however starting the alerter server normally takes only a few > > seconds, are there any known issues with using ServiceControlManager > > from within a service? > > > > Regards > > Robert. > > > > =================================== > > This list is hosted by DevelopMentor� http://www.develop.com > > Some .NET courses you may be interested in: > > > > Essential .NET: building applications and components with C# > > November 29 - December 3, in Los Angeles > > http://www.develop.com/courses/edotnet > > > > View archives and manage your subscription(s) at > http://discuss.develop.com > > > > > -- > Eric Means > [EMAIL PROTECTED] > http://www.randomtree.org/eric/ > > =================================== > This list is hosted by DevelopMentor� http://www.develop.com > Some .NET courses you may be interested in: > > Essential .NET: building applications and components with C# > November 29 - December 3, in Los Angeles > http://www.develop.com/courses/edotnet > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentor� http://www.develop.com Some .NET courses you may be interested in: Essential .NET: building applications and components with C# November 29 - December 3, in Los Angeles http://www.develop.com/courses/edotnet View archives and manage your subscription(s) at http://discuss.develop.com
