如何得到正常执行.NET中的堆栈跟踪?

编程入门 行业动态 更新时间:2024-10-28 18:24:13
本文介绍了如何得到正常执行.NET中的堆栈跟踪?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在VB .NET中,我知道我可以通过查看 ex.StackTrace 的价值得到一个堆栈跟踪处理异常的时候。我怎样才能在堆栈上的功能时,我没有处理异常?我希望实施某种形式的日志系统来记录用户系统崩溃之前采取的措施,协助调试。

In VB .NET, I know I can get a stack trace by looking at the value of ex.StackTrace when handling an exception. How can I get the functions on the stack when I am not handling an exception? I am looking to implement a logging system of some sort to record the steps the user takes prior to a crash to assist in debugging.

推荐答案

Environment.StackTrace 给你一个字符串,但更详细的信息和选项,使用堆栈跟踪类。

Environment.StackTrace gives you a string, but for more detailed information and options, use the StackTrace class.

要更具体,检查出的构造函数选项:

To be more specific, check out the constructor options:

msdn.microsoft/en-us/library/system.diagnostics.stacktrace.stacktrace.aspx

如果您需要的堆栈跟踪的调用者的帧开始(例如,在记录功能:你不想要的一切开始与 MyLogMethod ),你应该试试这个一个,这需要一个 INT 参数,跳帧的数量。

If you need the stack trace starting at the caller's frame (e.g. in a logging function: you don't want everything to start with MyLogMethod), you should try this one, which takes an int parameter, the number of frames to skip.

msdn.microsoft/en-us/library/wybch8k4.aspx

如果你需要没有源堆栈跟踪信息,(例如:如果你不想放弃你的源$ C ​​$ C信息),试试这个:

If you need the stack trace without source information (e.g. if you don't want to give away information about your source code), try this one:

msdn.microsoft/en-us/library/6zh7csxz.aspx

希望帮助!

更多推荐

如何得到正常执行.NET中的堆栈跟踪?

本文发布于:2023-11-17 06:17:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609124.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:堆栈   NET

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!