There is one static method on the ExceptionHelpers
Exception PrepareForRethrow(Exception exception);
The purpose of this method is to preserve the original stack trace of the exception so that it is not overwritten when the exception is rethrown.
The return value of this method should always be thrown immediately; that is, every call to this method should look like this:
Exception ex = ...; // get saved exception
if it is running on a machine with .NET 4.5 installed. If only .NET 4.0 is available, this method will fall back to the undocumented but somewhat common reflection hack of
. If both of these approaches fail (which may happen in Silverlight 5 or partial-trust .NET 4.0 scenarios), the original stack trace is added to the
property of the exception.