Ejemplo n.º 1
0
 /// <summary>
 /// Build the Exception string
 /// </summary>
 /// <param name="s"></param>
 /// <param name="depth"></param>
 /// <param name="ex"></param>
 private static void GetExceptionString(ref string s, int depth, Exception ex)
 {
     if (ex == null)
     {
         s += "EXCEPTIONERR   : No Exception found." + Environment.NewLine;
     }
     else
     {
         if (depth < ExceptionStringBuilderMaxDepth)
         {
             if (depth > 0)
             {
                 s += "INNEREXCEPTION   " + depth + Environment.NewLine;
             }
             s += "MESSAGE        : " + ex.Message + Environment.NewLine;
             s += "SOURCE         : " + ex.Source + Environment.NewLine;
             s += "TARGETSITE     : " + ex.TargetSite + Environment.NewLine;
             s += "STACKTRACE     : " + Environment.NewLine + ex.StackTrace.ToString() + Environment.NewLine;
             if (ex.InnerException != null)
             {
                 s += "-------------------------------------------------------" + Environment.NewLine;
                 s += Environment.NewLine;
                 depth++;
                 try
                 {
                     DGUIGHFFormStackTracer.GetExceptionString(ref s, depth, ex.InnerException);
                 }
                 catch
                 {
                     s += "EXCEPTIONERR   : There was an error loading this exception." + Environment.NewLine;
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Load the Stack Tracer Form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DGUIGHFFormStackTracer_Load(object sender, EventArgs e)
        {
            //setup the exception message

            string exceptionText = "";

            exceptionText += "EXCEPTION      : " + (m_unhandledException ? "Unhandled" : "Handled") + Environment.NewLine;

            try
            {
                string messageerr = m_ex.Message + "\n";
                label_errormessage.Text = "Error: " + messageerr;
            }
            catch { }

            try
            {
                DGUIGHFFormStackTracer.GetExceptionString(ref exceptionText, 0, m_ex);
            }
            catch
            {
                exceptionText += "EXCEPTIONERR   : There was an error loading this exception." + Environment.NewLine;
            }

            string exceptionDate      = String.Format("{0:yyyy-MM-dd HH:mm}", DateTime.UtcNow);
            string applicationName    = Assembly.GetEntryAssembly().GetName().Name.ToString();
            string applicationVersion = Assembly.GetEntryAssembly().GetName().Version.ToString();

            m_stacktracerMessage += "DATETIME       : " + exceptionDate + Environment.NewLine;
            m_stacktracerMessage += "SENDER         : " + m_stacktracerServiceFrom + Environment.NewLine;
            m_stacktracerMessage += "APPLICATION    : " + applicationName + Environment.NewLine;
            m_stacktracerMessage += "VERSION        : " + applicationVersion + Environment.NewLine;
            m_stacktracerMessage += Environment.NewLine;
            m_stacktracerMessage += exceptionText;

            textBox_stacktrace.Text = exceptionText;
        }