![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Exception stack is corrupt when catching and storing the exception 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; } } |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Exception stack is corrupt when catching and storing the excep The issue occurs in some production code, but i cant seem to reproduce the exact error in my debug envorinment. Therefore i want to collect the errors and then log them afterwards. But i can't seem to have full stack trace logged, unless i create a new instance of the StackTrace class, bu sincte the exceptions are a part of the public interface, i cannot just introduce the combination of StackTrace and Exception without changing the interface. Therefore i would like to know if there is any way to change the way .NET calculate the stackTrace to enable full stack logging always. "dlm@xxxxxx" wrote: Quote: > Hi Morten, > > have you tried to get full stack, debugging your code with SOS extensions enabled? With stack related commands (!clrstack, !dumpstack, !clrstack -p, !clrstack -l) you should get full picture of what's going on. > > Best regards, > dlm@xxxxxx > Compare SQL Server, MySQL and Oracle for free - DBTyP.NET > www.bypsoft.com > > > "Morten Herman Langkjaer" <MortenHermanLangkjaer@xxxxxx> schrieb im Newsbeitrag news:7F737C3F-F4A2-4389-86A9-9C67D383006F@xxxxxx Quote: > >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; > > } > > } > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Exception | PowerShell | |||
| .net security exception | .NET General | |||
| SqlClientPermission exception | .NET General | |||
| Vista Install Error: Exception Unknown Software Exception | Vista installation & setup | |||
| Unhandled exception at 0x779447f2 in explorer.exe: 0xC00000FD: Stack overflow. | Vista General | |||