An Exception object has a StackTrace property on it. But it is just a string.
Is there a way to get an actual System.Diagnostics.StackTrace object from an Exception?
I ask because I am getting the Exception object from an UnhandledExceptionEventHandler and I don't have access to the frame that generated the exception to get an actual Stack Trace.
StackTraceconstructors withExceptionargument? e.g.new StackTrace(ex).throw excalls. Note that if this is the case, then @IvanStoev's answer shouldn't work because theexis already missing the stack trace so I don't think theStackTraceconstructor will find anything to copy. See here for how to re-throw an exception without losing the stack trace in .NET 4.5+.