有关"StackTrace"的问题 [英] A question about "StackTrace"
问题描述
我有一个关于StackTrace的问题.
我正在使用"Embarcadero c ++ builder 2010".
我无法使用Exception类的StackTrace.
StackTrace属性始终使我为NULL.
我想在运行时看到调用堆栈.
请有人帮帮我.
下面是测试代码.
"st"始终为NULL.
Hi,
I have a question about StackTrace.
I am using "Embarcadero c++ builder 2010".
I have failed to use StackTrace of Exception class.
The StackTrace property always gives me NULL.
I want to see call stack while run time.
Please sombody help me.
Below is the test code.
The "st" is always NULL.
void TestFunc(int c)
{
try
{
String ss;
ss.sprintf(L"%s", 1111111111111111111);
}
catch (Exception& e)
{
String msg = e.Message;
String st = e.StackTrace;
}
}
预先感谢.
Thanks in advance.
推荐答案
必须为:
Must be:
void TestFunc(int c)
{
try
{
int test = 0;
test = test/test; //throw exception here;
}
catch (Exception ^ e)
{
String msg = e->Message;
String st = e->StackTrace;
//...
}
}
这个System :: Exception属性只是一个人类可读的字符串,您只能看一下它.
要使用堆栈进行高级操作,请使用System.Diagnostics::StackTrace
.
有关一个非常有趣的示例,请参阅我的文章:希望您在这里……只有一次,希望您在这里…只有一次 [ ^ ]: -).
This System::Exception property is just a human-readable string, you cannot do anything but look at it.
For advanced operation with stack use System.Diagnostics::StackTrace
.
For a very funny example, please see my article: Wish You Were Here… Only Once, Wish You Were Here… Only Once[^] :-).
这篇关于有关"StackTrace"的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!