Пример #1
0
 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.
     }
 }
Пример #2
0
        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);
        }
Пример #3
0
 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");
 }
Пример #4
0
        /// <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);
        }
Пример #5
0
 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);
     });
 }
Пример #6
0
        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);
        }
Пример #7
0
        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));
            }
        }
Пример #8
0
 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
             );
         }
     }
 }
Пример #9
0
        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;
            }
        }
Пример #10
0
 /// <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");
 }
Пример #11
0
        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();
            }
        }
Пример #13
0
    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." );
      }
    }
Пример #14
0
 private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e)
 {
     #if(DEBUG)
     Log.Error("FirstChanceException",e.Exception);
     #endif
 }
Пример #15
0
 private static void Program_FirstChanceException(object sender, FirstChanceExceptionEventArgs args)
 {
 }
Пример #16
0
 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);
     //}
 }
Пример #17
0
 static void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e)
 {
     ExceptionHandler(sender, e);
 }
Пример #18
0
 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));
 }
Пример #20
0
 /// <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);
 }
Пример #21
0
 private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e)
 {
 }
Пример #22
0
        static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e)
        {
            lock (typeof(MainClass))
            {
                using (var writer = File.AppendText(@"c:\1.txt"))
                {
                    writer.WriteLine(e.Exception.ToString());
                }
            }

        }
Пример #23
0
 private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e)
 {
     #if(DEBUG)
     Program.DebugTrace.TraceEvent(TraceEventType.Error, 0, e.Exception.ToString());
     #endif
 }
Пример #24
0
 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);
 }
Пример #25
0
 void CurrentDomain_FirstChanceException(object sender, System.Runtime.ExceptionServices.FirstChanceExceptionEventArgs e)
 {
 }
Пример #26
0
 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
 }
Пример #27
0
 private void _WriteError(object sender, FirstChanceExceptionEventArgs e)
 {
     Server._Logger.Error("error{0}", e.Exception.Message);
     Server._Logger.Error("error{0}", e.Exception.StackTrace);
 }
Пример #28
0
 private static void CurrentDomain_OnFirstChanceException(object sender, FirstChanceExceptionEventArgs args)
 {
     _firstChanceLog.Error("OnFirstChanceException", args.Exception);
 }
Пример #29
0
        private static void OnAppDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e)
        {
            lock (LastFirstChanceExceptions)
            {
                LastFirstChanceExceptions.Enqueue(e.Exception);

                while (LastFirstChanceExceptions.Count > 5)
                {
                    LastFirstChanceExceptions.Dequeue();
                }
            }
        }
Пример #30
0
 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);
 }
Пример #33
0
 private static void ExceptionTrapper(object sender, FirstChanceExceptionEventArgs e)
 {
     ExceptionsMeter.Mark();
     //Logger.Debug(e.Exception, "Thrown exception: {0}");
 }