private void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e) { if (!(e.Exception is UnKnownErrorException) && !(e.Exception is NegativeErrorException)) { //Do something here to monitor all hidden exceptions which are not handled appropriately. } }
private void FirstChanceExceptionHandler(object sender, FirstChanceExceptionEventArgs e) { if (e.Exception is SocketException) { return; } if (!string.IsNullOrWhiteSpace(e.Exception.Source) && e.Exception.Source.ToLower() == "mscorlib") { return; } var errorString = string.Format( "Sender: {0} FirstChanceException raised in {1} : Message -- {2} :: InnerException -- {3} :: TargetSite -- {4} :: StackTrace -- {5} :: HelpLink -- {6} ", sender, AppDomain.CurrentDomain.FriendlyName, e.Exception.Message, (e.Exception.InnerException != null) ? e.Exception.InnerException.Message : string.Empty, (e.Exception.TargetSite != null) ? e.Exception.TargetSite.Name : string.Empty, e.Exception.StackTrace ?? string.Empty, e.Exception.HelpLink ?? string.Empty); MessageBox.Show( errorString, "Error " + e.Exception.GetType(), MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK); }
public static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { if (e.Exception is InvalidCastException || e.Exception is System.Collections.Generic.KeyNotFoundException) return; WriteToLog.Log("A first chance exception was thrown", "EXCEPTION"); WriteToLog.Log(e.Exception.Message, "EXCEPTION"); WriteToLog.Log(e.ToString(), "EXCEPTION"); }
/// <summary> /// 处理FirstChanceException事件函数 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal static void OnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { if (System.Web.HttpContext.Current == null || e.Exception == null || e.Exception.Source == "Arch.CFramework.StartUp") return; if (System.Web.HttpContext.Current.Items[ItemName] == null) System.Web.HttpContext.Current.Items[ItemName] = new RequestException(); (System.Web.HttpContext.Current.Items[ItemName] as RequestException).Exceptions.Add(e.Exception); }
public void Should_handle_case_where_stacktrace_is_null() { var p = new PluginLogger(null); Assert.DoesNotThrow(() => { var args = new FirstChanceExceptionEventArgs(new COMException("blerg")); p.LogFirstChanceException(args); }); }
private static void OnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { var exception = e.Exception; if (exception == null) return; if (exception is OperationCanceledException) return; if (exception.Source == "nunit.framework") return; // sigh. if (exception.Source == "System.Xml") return; // sigh. Log.Warning(exception, "A first-chance exception was thrown by {ExceptionSource}", exception.Source); }
private static void FirstChanceException(object o, FirstChanceExceptionEventArgs e) { if (e.Exception is UnityConfigurationException) { var container = ((UnityConfigurationException)e.Exception).Container; container.RegisterInstance<ICache>(new DictionaryCache()); container.RegisterType(typeof(IDomainStatisticsDataSourceModule), typeof(JsonDataSource)); container.RegisterType(typeof(IUserModule), typeof(JsonUserModule)); } }
static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { if (e.Exception is NullReferenceException || e.Exception is ObjectDisposedException) { // Exclude safe handle messages because they are noisy if (!e.Exception.Message.Contains("Safe handle has been closed")) { var log = new EventLog("Application"); log.Source = "Application Error"; log.WriteEntry( "First-chance exception: " + e.Exception.ToString(), EventLogEntryType.Warning ); } } }
private static void FirstChanceHandler(object source, FirstChanceExceptionEventArgs e) { string executingAssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); try { TakeScreenshot(Path.Combine(executingAssemblyPath, "Screenshots", DateTime.Now.ToString("yyyyMMdd_HHmmssff") + ".png")); } catch { // Do nothing. Suppress any exceptions. } finally { AppDomain.CurrentDomain.FirstChanceException -= FirstChanceHandler; } }
/// <summary> /// Write to the log file on a crash /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { try { if (e.Exception.Message.Contains("too small for an int") || e.Exception.Message.Contains("Constructor on type ")) return; } catch { WriteToLog.Log("Failed to write error in FirstChanceException."); return; } WriteToLog.Log("A first chance exception was thrown", "EXCEPTION"); WriteToLog.Log(e.Exception.Message, "EXCEPTION"); WriteToLog.Log(e.Exception.StackTrace, "EXCEPTION"); }
public void OnException(object sender, FirstChanceExceptionEventArgs e) { //Notes down the line number of every first chance exception. //Then counts the occurences. Should make it easier to find what throws the most exceptions StackTrace trace = new StackTrace(e.Exception, true); StackFrame frame = trace.GetFrame(0); string heat = $"{frame.GetFileName()}:{frame.GetFileLineNumber()}"; if (_map.ContainsKey(heat)) { _map[heat]++; } else { _map[heat] = 1; } }
private static void CurrentDomainOnFirstChanceException(object sender, FirstChanceExceptionEventArgs firstChanceExceptionEventArgs) { if (ShallBypass()) { return; } try { Exception ex = firstChanceExceptionEventArgs.Exception; Debug.Assert(null != ex); // This commented code should stay here for debugging //if (ex is NullReferenceException) //{ // Tracer.Debug("NullReferenceException"); //} // Skipping reporting of the known exceptions if (IsExceptionKnown(ex)) { return; } if (IsExceptionOriginatedFromSystemAssembly(ex)) { Tracer.Trace("First chance exception from SYSTEM assembly: {0}", ex.ToDebugString()); } else { Tracer.Trace("First chance exception from USER assembly: {0}", ex.ToDebugString()); } } catch (Exception ex) { // We must not let ANY exception to escape this handler or we get infinite recursion Debug.WriteLine("Exception in exception notification handler!"); ex.Trace(); } }
static void CurrentDomain_FirstChanceException( object sender, FirstChanceExceptionEventArgs e ) { Exception exception = e.Exception; if( exception != null ) { StackTrace stackTrace = new StackTrace( 1 ); string stackTraceString = stackTrace.ToString(); if( stackTraceString.IndexOf( "xceed", StringComparison.InvariantCultureIgnoreCase ) >= 0 ) { lock( m_unknowSource ) { Log.WriteLine( m_unknowSource, exception.ToString() ); Log.WriteLine( "--------------------" ); Log.WriteLine( stackTraceString ); } } } else { Log.WriteLine( "FirstChanceException with a null/no exception." ); } }
private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { #if(DEBUG) Log.Error("FirstChanceException",e.Exception); #endif }
private static void Program_FirstChanceException(object sender, FirstChanceExceptionEventArgs args) { }
private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { //if (X.Instance.Debug) //{ // if (Program.GameMess != null && Program.GameEngine != null) Program.GameMess.Warning(e.Exception.Message + "\n" + e.Exception.StackTrace); //} }
static void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e) { ExceptionHandler(sender, e); }
private void _WriteError(object sender, FirstChanceExceptionEventArgs e) { _LogRecorder.Record($"Exception:{e.Exception.Message}\r\nStackTrace:{e.Exception.StackTrace}"); _LogRecorder.Save(); }
private static void AddAssertionInfo(object sender, FirstChanceExceptionEventArgs args) { AssertionImprover.AddAssertionSourceIfAvailable(args.Exception, new StackTrace(true).GetFrames().Skip(1)); }
/// <summary> /// Called when the program encounters any exception. Displays a message box to the user alerting them to the error. /// </summary> private void OnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { Exception Error = e.Exception; MessageBox.Show(Error.Message + Environment.NewLine + Error.StackTrace + Environment.NewLine); }
private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { }
static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { lock (typeof(MainClass)) { using (var writer = File.AppendText(@"c:\1.txt")) { writer.WriteLine(e.Exception.ToString()); } } }
private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { #if(DEBUG) Program.DebugTrace.TraceEvent(TraceEventType.Error, 0, e.Exception.ToString()); #endif }
static void FirstChanceHandler(object o, FirstChanceExceptionEventArgs e) { MethodBase site = e.Exception.TargetSite; Console.WriteLine("Thrown in module {0}, by {1}({2})", site.Module, site.DeclaringType, site.ToString()); Console.WriteLine("Stack trace:\n{0}", e.Exception.StackTrace); }
void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e) { }
private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { #if(DEBUG) //if (e.Exception.Message.Contains("agsXMPP.Xml.xpnet.PartialTokenException")) // System.Diagnostics.Debugger.Break(); //Program.DebugTrace.TraceEvent(TraceEventType.Error, 0, e.Exception.ToString()); #endif }
private void _WriteError(object sender, FirstChanceExceptionEventArgs e) { Server._Logger.Error("error{0}", e.Exception.Message); Server._Logger.Error("error{0}", e.Exception.StackTrace); }
private static void CurrentDomain_OnFirstChanceException(object sender, FirstChanceExceptionEventArgs args) { _firstChanceLog.Error("OnFirstChanceException", args.Exception); }
private static void OnAppDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { lock (LastFirstChanceExceptions) { LastFirstChanceExceptions.Enqueue(e.Exception); while (LastFirstChanceExceptions.Count > 5) { LastFirstChanceExceptions.Dequeue(); } } }
static void FirstChanceHandler(object source, FirstChanceExceptionEventArgs e) { logger.Error("FirstChanceException in {0}: {1}", AppDomain.CurrentDomain.FriendlyName, e.Exception.Message); }
/// <summary> /// On first chance exception event handler. /// </summary> /// <param name="eventArgs">The first chance exception event args.</param> protected override void OnFirstChanceException(FirstChanceExceptionEventArgs eventArgs) { if (this.exceptionsToTrack.Any() && (!this.exceptionsToTrack.Contains(eventArgs.Exception.GetType()))) { return; } DumpUtility.WriteDump(this.FileName, this.DumpType); }
private void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { if (Client.SendPIPE != null) Client.SendPIPE.WriteString("[" + "Exception" + "] " + e.Exception.Message); }
private static void ExceptionTrapper(object sender, FirstChanceExceptionEventArgs e) { ExceptionsMeter.Mark(); //Logger.Debug(e.Exception, "Thrown exception: {0}"); }