Example #1
0
        public static string StackTraceEx(this Exception exception)
        {
            if (exception == null)
            {
                return(string.Empty);
            }

            int HResult = (int)(exception.GetType().GetProperty("HResult", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(exception, null));

            return(string.Format("ErrorCode = {0} [ 0x{1:X} ]\nMessage = {2}\nStackTrace = {3}\n\r", HResult, HResult, exception.Message.RemoveLineBreak(), exception.StackTrace) + exception.AggregateStackTraces());
        }