static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { try { if (e.Exception.Message == "NoDriver calling waveInPrepareHeader") { //USB audio unplugged (typically the cause) - no other way to catch this exception in the volume level control due to limitation in NAudio } else { if (iSpyServer.iSpyServer.Default.Enable_Error_Reporting && _ReportedExceptionCount == 0 && e.Exception != null && e.Exception.Message != null && e.Exception.Message.ToString().Trim() != "") { if (_ER == null) { _ER = new ErrorReporting(); _ER.UnhandledException = e.Exception; _ER.ShowDialog(); _ER.Dispose(); _ER = null; _ReportedExceptionCount++; } } } MainForm.LogExceptionToFile(e.Exception); } catch (Exception ex2) { MainForm.LogExceptionToFile(ex2); } }
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 { } } }