M
Morten Herman Langkjaer
i have som code that does e number of operatoins, if any exception occurs
during the execution path, the exception is stored in a list, and in another
place, the errors are logged. for example, method a calls b, that calls c. c
throws an exception, that b stores. When using the exception.ToString(), only
method b and c appears in the stack trace. Sine the method is called from
several locations, i cannot find the execution paths without attaching a
debugger. Is this a feature/bug in the framework. Can anyone help me get the
full stack trace.
i have created a simple application that proves the problem, it is written
in C#, and is a console application. try reviewing the following:
using System;
using System.Diagnostics;
namespace testStack
{
class Program
{
static void Main(string[] args)
{
try
{
StoredErrorThrower();
}
catch( Exception e )
{
Console.Out.WriteLine();
Console.Out.WriteLine("Non stored exception stack trace");
Console.Out.WriteLine();
Console.Out.WriteLine(e);
}
Console.Out.WriteLine();
Console.Out.WriteLine();
Console.Out.WriteLine("Stored Exception stack trace:");
Console.Out.WriteLine();
Console.Out.WriteLine(error);
Console.Out.WriteLine();
Console.Out.WriteLine();
Console.Out.WriteLine("Stack frame from the stored exception handler");
Console.Out.WriteLine(frame);
}
private static void StoredErrorThrower()
{
try
{
throw new Exception("error");
}
catch( Exception e )
{
frame = new StackTrace();
error = e;
}
throw new Exception("error");
}
private static Exception error;
private static StackTrace frame;
}
}
during the execution path, the exception is stored in a list, and in another
place, the errors are logged. for example, method a calls b, that calls c. c
throws an exception, that b stores. When using the exception.ToString(), only
method b and c appears in the stack trace. Sine the method is called from
several locations, i cannot find the execution paths without attaching a
debugger. Is this a feature/bug in the framework. Can anyone help me get the
full stack trace.
i have created a simple application that proves the problem, it is written
in C#, and is a console application. try reviewing the following:
using System;
using System.Diagnostics;
namespace testStack
{
class Program
{
static void Main(string[] args)
{
try
{
StoredErrorThrower();
}
catch( Exception e )
{
Console.Out.WriteLine();
Console.Out.WriteLine("Non stored exception stack trace");
Console.Out.WriteLine();
Console.Out.WriteLine(e);
}
Console.Out.WriteLine();
Console.Out.WriteLine();
Console.Out.WriteLine("Stored Exception stack trace:");
Console.Out.WriteLine();
Console.Out.WriteLine(error);
Console.Out.WriteLine();
Console.Out.WriteLine();
Console.Out.WriteLine("Stack frame from the stored exception handler");
Console.Out.WriteLine(frame);
}
private static void StoredErrorThrower()
{
try
{
throw new Exception("error");
}
catch( Exception e )
{
frame = new StackTrace();
error = e;
}
throw new Exception("error");
}
private static Exception error;
private static StackTrace frame;
}
}