以编程方式转储调用堆栈 [英] Dumping the call stack programmatically
本文介绍了以编程方式转储调用堆栈的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
寻找一种在遇到任何代码段时以编程方式转储调用堆栈和.net Win Forms应用程序的方法。这是我以前从未遇到过的事情,但是可以节省一些调试时间。
Looking for a way to programmatically dump the call stack and a .net Win Forms app when ever a section of code is hit. Its something I haven't come across before but will save me some debug time.
更新:忘记添加了,这会增加应用程序多少开销,即
Update: Forgot to add, how much overhead would this add to the application , i.e. would it slow it down considerably.
推荐答案
System.Environment.StackTrace
将以字符串形式提供当前堆栈。
Will give you the current stack as a string.
如果您有更高级的需求,也可以使用 StackTrace
类,就像其他人指出的那样。
You can also use the StackTrace
class as others have pointed out if you have more advanced needs.
这篇关于以编程方式转储调用堆栈的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文