static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) { try { var ex = (Exception)e.ExceptionObject; if (MainForm.Conf.Enable_Error_Reporting && _reportedExceptionCount == 0) { if (_er == null) { _er = new ErrorReporting { UnhandledException = ex }; _er.ShowDialog(); _er.Dispose(); _er = null; _reportedExceptionCount++; } } MainForm.LogExceptionToFile(ex); } catch (Exception ex2) { try { MainForm.LogExceptionToFile(ex2); } catch { } } }
private static void ApplicationThreadException(object sender, ThreadExceptionEventArgs e) { try { if (e!=null && e.Exception!=null && !String.IsNullOrEmpty(e.Exception.Message) && e.Exception.Message.IndexOf("NoDriver", StringComparison.Ordinal)!=-1) { //USB audio plugged/ unplugged (typically the cause) - no other way to catch this exception in the volume level control due to limitation in NAudio } else { if (MainForm.Conf.Enable_Error_Reporting && _reportedExceptionCount == 0 && e!=null && e.Exception != null && e.Exception.Message.Trim() != "") { if (_er == null) { _er = new ErrorReporting {UnhandledException = e.Exception}; _er.ShowDialog(); _er.Dispose(); _er = null; _reportedExceptionCount++; } } } if (e!=null) MainForm.LogExceptionToFile(e.Exception); } catch (Exception ex2) { try { MainForm.LogExceptionToFile(ex2); } catch { } } }