/// <summary> /// The main entry point for the application. /// </summary> private static void Main() { // Start the main program running try { if (mMainProcess == null) { mMainProcess = new MainProgram(); if (!mMainProcess.InitMgr()) { PRISM.Logging.FileLogger.FlushPendingMessages(); return; } mMainProcess.DoDirectoryCreation(); } } catch (Exception ex) { var errMsg = "Critical exception starting application: " + ex.Message; ConsoleMsgUtils.ShowWarning(errMsg + "; " + StackTraceFormatter.GetExceptionStackTrace(ex)); ConsoleMsgUtils.ShowWarning("Exiting clsMainProcess.Main with error code = 1"); } PRISM.Logging.FileLogger.FlushPendingMessages(); }
public void VerifyExceptionStackTrace(ExceptionTypes targetException, int depth, bool multiLine, bool includeMethodParams = false) { var parents = new List <string>(); try { RecursiveMethodA(targetException, parents, 1, depth); } catch (Exception ex) { string stackTrace; if (multiLine) { stackTrace = StackTraceFormatter.GetExceptionStackTraceMultiLine(ex, true, includeMethodParams); } else { stackTrace = StackTraceFormatter.GetExceptionStackTrace(ex); } Console.WriteLine(stackTrace); } }
private static void ShowError(string message, Exception ex = null) { Console.WriteLine(); var msg = "Error: " + message; ConsoleMsgUtils.ShowError(msg, ex); mLogFile?.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "\t" + msg); if (ex != null) { mLogFile?.WriteLine(DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss tt") + "\t" + StackTraceFormatter.GetExceptionStackTrace(ex)); } }