private void LogMessage(FirstChanceExceptionEventArgs e) { Logger.Error(e.Exception.Message); if (e.Exception.InnerException != null) { Logger.Error(e.Exception.InnerException.ToString()); } if (e.Exception.StackTrace != null) { Logger.Error(e.Exception.StackTrace); } }
private static void FirstChanceExceptionHandler(object sender, FirstChanceExceptionEventArgs args) { if (handlerActive.Value) { return; } bool oom = args.Exception is OutOfMemoryException; //In case of OOM, unload the Main.tile array and do immediate garbage collection. //If we don't do this, there will be a big chance that this method will fail to even quit the game, due to another OOM exception being thrown. if (oom) { Main.tile = null; GC.Collect(); } try { handlerActive.Value = true; if (!oom) { if (args.Exception == previousException || args.Exception is ThreadAbortException || ignoreSources.Contains(args.Exception.Source) || ignoreMessages.Any(str => args.Exception.Message?.Contains(str) ?? false) || ignoreThrowingMethods.Any(str => args.Exception.StackTrace?.Contains(str) ?? false)) { return; } } var stackTrace = new StackTrace(true); PrettifyStackTraceSources(stackTrace.GetFrames()); var traceString = stackTrace.ToString(); if (!oom && ignoreContents.Any(traceString.Contains)) { return; } traceString = traceString.Substring(traceString.IndexOf('\n')); var exString = args.Exception.GetType() + ": " + args.Exception.Message + traceString; lock (pastExceptions) { if (!pastExceptions.Add(exString)) { return; } } previousException = args.Exception; var msg = args.Exception.Message + " " + Language.GetTextValue("tModLoader.RuntimeErrorSeeLogsForFullTrace", Path.GetFileName(LogPath)); #if CLIENT if (ModCompile.activelyModding) { AddChatMessage(msg, Color.OrangeRed); } #else Console.ForegroundColor = ConsoleColor.DarkMagenta; Console.WriteLine(msg); Console.ResetColor(); #endif tML.Warn(Language.GetTextValue("tModLoader.RuntimeErrorSilentlyCaughtException") + '\n' + exString); if (oom) { string error = Language.GetTextValue("tModLoader.OutOfMemory"); Logging.tML.Fatal(error); Interface.MessageBoxShow(error); Environment.Exit(1); } } catch (Exception e) { tML.Warn("FirstChanceExceptionHandler exception", e); } finally { handlerActive.Value = false; } }
private void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { _logger.Exception(e.Exception, "CurrentDomain_FirstChanceException"); }
private static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { throw new NotImplementedException(); }
static void FirstChanceHandler(object source, FirstChanceExceptionEventArgs e) { Console.WriteLine("FirstChanceException event raised in {0}: {1}", AppDomain.CurrentDomain.FriendlyName, e.Exception.Message); }
private static void ExceptionTrapper(object sender, FirstChanceExceptionEventArgs e) { //Logger.Debug(e.Exception, "Thrown exception: {0}"); }
public void FirstChanceHandler(object source, FirstChanceExceptionEventArgs e) { this.logger.LogDebug("FirstChanceException event raised in {0}: {1}", AppDomain.CurrentDomain.FriendlyName, e.Exception); }
private void OnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { this.WriteException(e.Exception as Exception); }
private void FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { _logger.Error("FirstChanceException : " + e.Exception); }
private static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { }
private static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { AnalogyLogger.Intance.LogException(e.Exception, nameof(CurrentDomain_FirstChanceException), "Error: " + e); }
public void FirstChanceExceptionTrapper(object sender, FirstChanceExceptionEventArgs e) { LogMessage(e); }
private void FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { var name = e.Exception.GetType().Name; _statsd.Increment("runtime.dotnet.exceptions.count", 1, tags: new[] { $"exception_type:{name}" }); }
private void CurrentDomainFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { #if (DEBUG) Program.DebugTrace.TraceEvent(TraceEventType.Error, 0, e.Exception.ToString()); #endif }
/// <summary> /// 当アプリケーションで例外が発生した際に最初に呼ばれるイベントハンドラです。 /// </summary> /// <param name="sender">イベント送信元オブジェクト</param> /// <param name="e">イベント引数オブジェクト</param> private void App_OnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { LogManager.Error(JenkinsNotificationTool.Properties.Resources.FirstChanceExceptionMessage, e.Exception); }
private void CurrentDomainOnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { _logger.Error(e.Exception); }
public static void SecurityExceptionHandler(FirstChanceExceptionEventArgs e) { ShowLoginWindow(e); }
private void exception(object sender, FirstChanceExceptionEventArgs e) { var v = e.Exception; }
private void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { this.startupProfiler?.Exception(e.Exception); }
private void CurrentDomainOnFirstChanceException(object sender, FirstChanceExceptionEventArgs firstChanceExceptionEventArgs) { var exception = firstChanceExceptionEventArgs.Exception; }
private static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { Log.Info(e.Exception.Message, e.Exception); }
/// <summary> /// Handles the FirstChanceException event of the CurrentDomain control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="FirstChanceExceptionEventArgs" /> instance containing the event data.</param> private static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { _loggerMessageError(_appDomainExceptionLogger, e.Exception.GetAllMessages(), e.Exception); }
private void CalculateStatistics(object sender, FirstChanceExceptionEventArgs firstChanceExceptionArgs) { // this is thread local variable. No need to lock if (executionSyncObject == LOCKED) { return; } try { Exception exception; string exceptionType; System.Diagnostics.StackFrame exceptionStackFrame; string problemId; string methodName = "UnknownMethod"; int methodOffset = System.Diagnostics.StackFrame.OFFSET_UNKNOWN; bool getOperationName = false; executionSyncObject = LOCKED; if (this.MovingAverageTimeout < DateTime.UtcNow.Ticks) { lock (this.movingAverageLockObject) { if (this.MovingAverageTimeout < DateTime.UtcNow.Ticks) { if (this.MovingAverageTimeout + TicksMovingAverage < DateTime.UtcNow.Ticks) { this.currentMovingAverage = 0; } else { this.currentMovingAverage = (this.currentMovingAverage * CurrentWeight) + (((double)this.newProcessed) * NewWeight); } this.newThreshold = (long)((this.TargetMovingAverage - (this.currentMovingAverage * CurrentWeight)) / NewWeight); this.newProcessed = 0; this.MovingAverageTimeout = DateTime.UtcNow.Ticks + TicksMovingAverage; } } } exception = firstChanceExceptionArgs?.Exception; if (exception == null) { WindowsServerEventSource.Log.FirstChanceExceptionCallbackExeptionIsNull(); return; } if (WasExceptionTracked(exception) == true) { return; } exceptionType = exception.GetType().FullName; exceptionStackFrame = new System.Diagnostics.StackFrame(1); if (exceptionStackFrame != null) { MethodBase methodBase = exceptionStackFrame.GetMethod(); if (methodBase != null) { methodName = (methodBase.DeclaringType?.FullName ?? "Global") + "." + methodBase.Name; methodOffset = exceptionStackFrame.GetILOffset(); } } if (methodOffset == System.Diagnostics.StackFrame.OFFSET_UNKNOWN) { problemId = exceptionType + " at " + methodName; } else { problemId = exceptionType + " at " + methodName + ":" + methodOffset.ToString(CultureInfo.InvariantCulture); } if (this.newProcessed < this.newThreshold) { Interlocked.Increment(ref this.newProcessed); getOperationName = true; } this.TrackStatistics(getOperationName, problemId, exception); } catch (Exception exc) { try { WindowsServerEventSource.Log.FirstChanceExceptionCallbackException(exc.ToInvariantString()); } catch (Exception) { // this is absolutely critical to not throw out of this method // Otherwise it will affect the customer application behavior significantly } } finally { executionSyncObject = UNLOCKED; } }
/// <summary> /// The exception log handler. /// </summary> /// <param name="source"> /// The class where the exception was thrown. /// </param> /// <param name="e"> /// The <see cref="EventArgs"/> for the exception. /// </param> private static void ExceptionLogHandler(object source, FirstChanceExceptionEventArgs e) { Logger.Error($"\n\tError: '{e.Exception.Message}' thrown in '{source?.GetType()}: {e.Exception.StackTrace}'\n"); }
private static void CurrentDomainOnFirstChanceException(object?sender, FirstChanceExceptionEventArgs e) { ErrorLog.AppendLine("First chance exception", e.Exception.ToString()); }
private static void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { HandleException((Exception)e.Exception, "FirstChanceException"); }
private void OnException(object sender, FirstChanceExceptionEventArgs e) { string str = e.Exception.ToString(); Log += "[Exception]" + str.ToString() + "\r\n"; }
public static void HandleFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { if (isReentrant) { return; } isReentrant = true; try { var ex = e.Exception; if (ex is EntryPointNotFoundException) { if (ex.Message.Contains("Unable to find an entry point named 'ReadFile'")) { return; } } if (ex is InvalidCastException) { if (ex.Message.Contains("Invalid cast from 'System.String' to")) { return; } if (ex.Message.Contains("Unable to cast object of type 'Microsoft.Build.Tasks.Windows.MarkupCompilePass1' to type 'Microsoft.Build.Framework.ITask'.")) { return; } } if (ex is InvalidOperationException) { if (ex.Message.Contains("An attempt was made to transition a task to a final state when it had already completed.")) { return; } } if (ex is AggregateException) { return; } if (ex is DecoderFallbackException) { return; } if (ex is DirectoryNotFoundException) { return; } if (ex is Microsoft.Build.Exceptions.InvalidProjectFileException) { return; } if (ex is FileLoadException && ex.Message.Contains("The assembly '' has already loaded from a different location")) { return; } if (ex is FileNotFoundException) { return; } if (ex is MissingMethodException) { // MSBuild evaluation has a known one return; } if (ex is XmlException && ex.Message.Contains("There are multiple root elements")) { return; } if (knownMessages.Contains(ex.Message)) { return; } string exceptionType = ex.GetType().FullName; if (exceptionType.Contains("UnsupportedSignatureContent")) { return; } string stackTrace = ex.StackTrace; if (stackTrace.Contains("Antlr")) { return; } if (stackTrace.Contains("at System.Guid.StringToInt")) { return; } var trace = new TraceFactory().Manufacture(ex); if (trace.Select(f => f.Method.Module).Any(IgnoredModules.Contains)) { return; } var message = DateTime.Now.ToString() + ": First chance exception"; if (SolutionGenerator.CurrentAssemblyName != null) { message += " while processing assembly: " + SolutionGenerator.CurrentAssemblyName; if (SolutionGenerator.CurrentAssemblyName == "Microsoft.VisualStudio.Diagnostics.ManagedHeapAnalyzerUnitTests" && ex.Message.Contains("The network path was not found")) { // their project file isn't authored correctly but we deal with it well // so just ignore this one return; } } Log.Exception(ex, message, isSevere: false); } finally { isReentrant = false; } }
private void LogFirstChanceException(object _, FirstChanceExceptionEventArgs e) { LogTo.Error(e.Exception, "First chance exception"); }
private void CurrentDomain_FirstChanceException(object sender, FirstChanceExceptionEventArgs e) { // Debugger.Break(); }
/*static private Assembly AssemblyResolveHandler(object sender, ResolveEventArgs args) * { * //This handler is called only when the common language runtime tries to bind to the assembly and fails. * * string strTempAssmbPath = ""; * * //Retrieve the list of referenced assemblies in an array of AssemblyName. * Assembly objExecutingAssemblies = Assembly.GetExecutingAssembly(); * AssemblyName[] arrReferencedAssmbNames = objExecutingAssemblies.GetReferencedAssemblies(); * * //Loop through the array of referenced assembly names. * foreach (AssemblyName strAssmbName in arrReferencedAssmbNames) * { * //Check for the assembly names that have raised the "AssemblyResolve" event. * if (strAssmbName.FullName.Substring(0, strAssmbName.FullName.IndexOf(",")) == args.Name.Substring(0, args.Name.IndexOf(","))) * { * //Build the path of the assembly from where it has to be loaded. * //The following line is probably the only line of code in this method you may need to modify: * if(System.Environment.Is64BitProcess) * strTempAssmbPath = appPath + @"\x64\"; * else * strTempAssmbPath = appPath + @"\x86\"; * strTempAssmbPath += args.Name.Substring(0, args.Name.IndexOf(",")) + ".dll"; * break; * } * } * * //Load the assembly from the specified path. * Assembly MyAssembly = Assembly.LoadFrom(strTempAssmbPath); * * //Return the loaded assembly. * return MyAssembly; * }*/ static private void FirstChanceExceptionHandler(object source, FirstChanceExceptionEventArgs e) { AppLog.Debug("FirstChanceException event raised in {0}: {1}\r\n{2}", AppDomain.CurrentDomain.FriendlyName, e.Exception.Message, e.Exception.StackTrace); }
private static void CurrentDomainOnFirstChanceException(object sender, FirstChanceExceptionEventArgs e) { Debug.WriteLine(e.Exception.Message); Debug.WriteLine(e.Exception.StackTrace); }