Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get StackTrace without Exception in Windows Universal 10 App

I know it was possible to use:

System.Diagnostics.StackTrace t = new System.Diagnostics.StackTrace();

but that seems to not work anymore, as it needs an Exception-Object.

like image 590
Jens Marchewka Avatar asked Aug 06 '15 14:08

Jens Marchewka


People also ask

How do I activate StackTrace?

Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

What is exception StackTrace?

A trace of the method calls is called a stack trace. The stack trace listing provides a way to follow the call stack to the line number in the method where the exception occurs. The StackTrace property returns the frames of the call stack that originate at the location where the exception was thrown.

How to get a stack trace from an error?

Use the console. trace() method to get the stack trace from an error. The console. trace() method outputs the stack trace and shows the call path taken to reach the point at which the method was called.

How to get stack trace in windows?

Each thread has its own call stack, representing the calls made in that thread. To get a stack trace, use the methods GetStackTrace and GetContextStackTrace. A stack trace can be printed using OutputStackTrace and OutputContextStackTrace.


1 Answers

Try Environment.StackTrace. Just remember to be careful with what your logic afterwards is as stacks can change in unpredictable ways. Some discussion here: https://github.com/dotnet/corefx/issues/1420

like image 69
Matt Whilden Avatar answered Sep 28 '22 22:09

Matt Whilden