I wrote:
> I have a singel-threaded Windows service in C#. Its main
> loop is wrapped in a `try' block, and I am logging the
> exception the `catch' block. I have also subscribed to
>
> AppDomain.CurrentDomain.UnhandledException
>
> and am logging it too, as well the Start and Stop
> commands. Yet my client reports that sometimes my service
> stops without writing anything in the log. What can be
> the cause if the log file is accessible (the service adds
> an entry at start-up) and nobody is stopping the service
> process via Task manager (I belive them they don't)? How
> can I diagnose the situation?
After more than a year, I am back at it.
Marcel Mueller:
> There are two exceptions that can't be handled gracefully:
> - out of memory and
> - stack overflow.
Understandable, but I don't think either of them happened.
And if it did, is there a standard Windows or .NET facility
that can detect and log those exceptions, or preferably any
unhandled exceptions in any .NET application?
> An of course unmanaged code may always cause crashes as
> well.
Our service uses COM-objects, so that is another possiblity.
> There is also a small chance that race conditions crash
> the entire application. Even if your service is single
> threaded AFAIK this does not apply to SCM events.
Yes, mine is a single-threaded service (KISS). Do you mean
a race condition related to the service's handling of a
command sent via SCM? I am logging all the events that my
service handles, which are only two: OnStart() and OnStop().
Yet nothing appears in the log after abnormal terminations.
> Have a look at the system logfiles. Unhandled program
> terminations are usually logged there.
All I have found is entries in the event Journal saying that
the service terminated unexpectedly.
Has anybody used ADPlus -- a Visual Basic script that
facilitates the troubleshooting of handing or crashing
programs:
https://support.microsoft.com/en-us/help/286350/how-to-use-adplus-vbs-to-troubleshoot-hangs-and-crashes