<p>On a Windows 2003 server I have a pure .NET 3.5 <code>C#</code> app (no unmanaged code). It connects to various other remote systems via sockets and acts like a data hub. It runs for 10-15 hours fine with no problem but from time to time it just disappears. If I watch the app using task manager the memory usage remains constant.</p>

<p>In the <code>Main()</code> function I wrap the invocation of the rest of the app in a <code>try .. catch</code> block which it just blows completely past - the catch block which logs the exception to a file is ignored. If I manually raise an exception for testing, the catch block is invoked.</p>

<p>Prior to entering the <code>try .. catch</code> I do :</p>

<pre><code>Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
</code></pre>

<p>The system has Dr. Watson on it, but nothing gets written in the directory <code>DRWTSN32.EXE</code> is pointing to.</p>

<p>How can I catch whatever exception is causing this?</p>

If it's a Windows Forms application, you could try
```
Application.ThreadException
```
.