using System.Diagnostics;
using System.Runtime.CompilerServices;
public static void Main()
Console.WriteLine("Hello World");
Console.WriteLine("Top-level:" + ex.ToString());
static void F2() { F4(); }
static void F3() { F4(); }
throw new Exception("boo");
Console.WriteLine($"Lower-level:" + ex.FullStackTrace());
public static class ExceptionExtensions
[MethodImpl(MethodImplOptions.NoInlining)]
public static string FullStackTrace(this Exception ex)
var st = new StackTrace(2, true);
return ex.ToString() + Environment.NewLine + st.ToString();