开发者

What is stopping (not crashing) my windows service?

We have a .NET Windows Service that occasionally shuts down on one particular se开发者_开发技巧rver, about three times in the last month. Logging shows that the OnStop method is being called, so I don't think the service is crashing. However, we don't know what's shutting down the service.

Is there any way to find out what's shutting down the service? Is there anything I can log during OnStop? The Windows Event Viewer just shows application shut down and the security log does not show any user account authenticated at the time.

The service is running in .NET 3.5 SP1 on Windows Server 2003 SP2 (5.2.3790).

There are no service dependencies. This service doesn't depend on any other services and no other services depend on this service.


There is no way to tell from within the service since this called from the SCM - whoever asked SCM to stop your service isn't visible to the service...

I think your main option is checking the EventLog around that time... are other services being shutdown too ? is any scheduled taks running etc. ?

A "rather dirty" option (last resort/desperate) would be to set CanStop to false... in this case there will be someone seeing a problem in stopping your service and "hopefully" ask you why your service is not stoppable...


From my limited experience, permissions and security can tend to cause all sorts of problems for windows services.

Under what account does the service run? (E.g. System account, network service etc).

Something I've had to do in the past is setting up the service to run under a network account with appropriate permissions. You can do this from the Properties window (right-click on the service in the 'Services' management console. In the Log On select This account and choose the account you want to use and enter the account password.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜