What does stopping (not crashing) my window mean?

We have a Windows.NET service that sometimes shuts down on one specific server, about three times in the last month. Logging shows that the OnStop method is OnStop called, so I don't think the service is crashing. However, we do not know what disables the service.

Is there any way to find out what disables the service? Is there anything I can register during OnStop ? The Windows Event Viewer simply shows that the application is closing, and the user account authenticated at that time is not displayed in the security log.

The service runs on .NET 3.5 SP1 on Windows Server 2003 Service Pack 2 (5.2.3790).

No service dependencies. This service is independent of any other services, and no other services are dependent on this service.

+6
source share
2 answers

It is impossible to tell from inside the service, since it is called from SCM - whoever asked SCM to stop your service is not displayed to the service ...

I think your main option is to check the EventLog around this time ... are other services also disabled? are there any planned taks etc.?

A “rather dirty” option (the last option / desperate) is to set CanStop to false ... in this case, someone will see a problem with stopping your service and “hope” will ask you why your service is not stopping. ..

+3
source

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

What account does the service run in? (For example, a system account, network service, etc.).

Something I needed to do in the past was to configure the service to run under a network account with the appropriate permissions. You can do this from the Properties window (right-click on a service in the Services management console. In the Login window, select This account > and select the account you want to use and enter the account password.

0
source

Source: https://habr.com/ru/post/893656/


All Articles