Exemplo n.º 1
0
        private static string GetStackInfo(Exception ex)
        {
            StringBuilder builder = new StringBuilder();
            int           num     = 0;

            foreach (StackFrame frame in new StackTrace(ex).GetFrames())
            {
                builder.Append(" -");
                int        iLOffset = frame.GetILOffset();
                MethodBase method   = frame.GetMethod();
                if ((method != null) && (method.DeclaringType != null))
                {
                    builder.Append(method.DeclaringType.FullName);
                }
                if (method != null)
                {
                    builder.Append(" " + method.ToString());
                }
                builder.Append(" offset: 0x" + iLOffset.ToString("X"));
                builder.AppendLine();
                if ((((iLOffset > 0) && (method != null)) && (method.ReflectedType != null)) && !method.ReflectedType.Namespace.StartsWith("System", StringComparison.Ordinal))
                {
                    try
                    {
                        builder.AppendLine("   " + Disassembler.Disassemble(method, iLOffset - 0x19, iLOffset + 0x19).Replace("\n", "\n   "));
                    }
                    catch (Exception exception)
                    {
                        builder.AppendLine("   <" + exception.Message + ex.StackTrace + ">");
                    }
                }
                builder.AppendLine();
                num++;
            }
            return(builder.ToString());
        }
Exemplo n.º 2
0
 public static string Disassemble(this MethodBase method)
 {
     return(Disassembler.Disassemble(method));
 }