All right, I've inherited some code and the guy who started writing the code has a bad habit of squelching exceptions, thus making my life difficult. So as I look through the code I'm trying to toss something in the catch blocks so I can figure out what's going on. Since this is a Windows Forms application, I cannot write to the console itself, however I can write to the Debug console. I'd like to change the text foreground color when I hit one of these (previously) squelched exceptions so that I can easily pick them out as I debug. Of course, the other reason for writing to the debug console is so that the customer does not see these messages in the final design. Is there any way to do this? I've tried the following code, but it does not quite do it.
catch
{
ConsoleColor tempColor = Console.ForegroundColor;
StackTrace stackTrace = new StackTrace();
Console.ForegroundColor = ConsoleColor.Red;
System.Diagnostics.Debug.WriteLine("Exception Thrown: " + stackTrace.GetFrame(0).GetMethod().ToString());
Console.ForegroundColor = tempColor;
}
a.txt,b.txt...z.txtone at a time. At some point it becomes a "boy who cried wolf" type deal). The other, and more important issue is that the software I'm working on makes heavy use of DLL's, so the debugger can't tell me where the exception was thrown, only the DLL name.