How to get StackTrace without Exception in Windows Universal 10 App

你说的曾经没有我的故事 提交于 2019-12-18 05:59:31

问题


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.


回答1:


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




回答2:


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.




回答3:


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



来源:https://stackoverflow.com/questions/31859169/how-to-get-stacktrace-without-exception-in-windows-universal-10-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!