unhandled exception in windows service application
<p>I would like to catch unhandled exceptions in a windows service application in the class that inherits from ServiceBase class.
I have already tried incorporating the code:</p>

<pre><code>AppDomain.CurrentDomain.UnhandledException += (s, e) =&gt;
        {
            var exception = (Exception)e.ExceptionObject;
            Log.Error("Unhandled exception", exception);
        };
</code></pre>

<p>But that doesn't work.</p>