Hello is there a class that does a pretty conversion? Thanks.
+3
A:
There isn't anything built in, but it would be fairly easy.
Just grab the StackTrace:
// Create trace from exception
var trace = new System.Diagnostics.StackTrace(exception);
// or for current code location
var trace = new System.Diagnostics.StackTrace(true);
Once you have this, just iterate the stack frames, and format them as desired.
There would be lots of ways to format this into HTML - it really depends on how you want it to look. The basic concept would be:
int frameCount = trace.Framecount;
for (int i=0;i<frameCount;++i)
{
var frame = trace.GetFrame(i);
// Write properties to formatted HTML, including frame.GetMethod()/frame.GetFileName(), etc.
// The specific format is really up to you.
}
Reed Copsey
2009-09-05 02:16:03