views:

13

answers:

1

I've written a custom service that overrides ServiceBase.OnShutdown(). Unfortunately, when I log to the event log, nothing is written. My guess is that the Windows event log was shut down before my service. Is there a way to order service shutdown so that my servce shuts down before the event logger? I don't want to have to write out to a file. Pl. advise. Thanks.

A: 

You could try to setup a dependency where your service depends on the Event logger, this is mostly done to make them load in the correct order but I assume that might make sure that your service always was stopped first as well.
As can be seen in this Technet article, you'd need to change the DependOnService value either using the Sc.exe tool or the ChangeServiceConfig API.

ho1
fyi - I saw some post somewhere (not very helpful I know) that said this didn't work.
Rory