简体   繁体   中英

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.

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

Check out this discussion on .NET Core's github : Where have StackTrace and StackFrame gone? .

This class isn't there in .NET Core, but there's an open task to implement it: Implement System.Diagnostics.StackTrace/StackFrame - just no one actively working on it yet.

As a workaround until .Net Core 2.0 will be available you can parse Environment.StackTrace string as suggested in answeres to How to split a stacktrace line into namespace, class, method file and line number? -using RegEx or StackTraceParser

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM