I am getting an exception in the windows service I'm working on. It does not fall into any of my try / catch blocks (which I have everywhere), but I see this in the Windows event log. Is there a way to make an exception in the event log include line numbers?
Subscribe to the AppDomain.CurrentDomain.UnhandledException event and you will not miss the unhandled exception:
AppDomain.CurrentDomain.UnhandledException
public static void Main() { AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; // Service Run } static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { // log exception e.ExceptionObject }