How to rethrow InnnerException without losing Stack Trace in C# ?

Microsoft .NET Framework 4.5  introduced the ExceptionDispatchInfo class which lets the developers to capture an exception and rethrow it without losing the stack trace.

How to rethrow InnnerException without losing Stack Trace in C# ?

Below is a sample code snippet demonstrating the usage of this class.

try
{
    // Execute method
}
catch(Exception ex)
{
    ExceptionDispatchInfo.Capture(ex.InnerException).Throw();
}