如何从我的例子中读取c#的堆栈跟踪?

时间:2012-04-10 07:28:09

标签: c# stack-trace

如何阅读此堆栈跟踪? 谁能解释我如何理解这个来解决这个问题。

"Frame    Image             Function                                                             Offset    
0        coredll.dll       xxx_RaiseException                                                   19        
1        mscoree3_7.dll                                                                         436488    
2        mscoree3_7.dll                                                                         386545    
3        mscoree3_7.dll                                                                         540936    
4                          TransitionStub                                                       0         
5                          GeoCaching.Main.btnGoToPin_Click                                     312       
6                          System.Windows.Controls.Primitives.ButtonBase.OnClick                132       
7                          System.Windows.Controls.Button.OnClick                               120       
8                          System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp    228       
9                          System.Windows.Controls.Control.OnMouseLeftButtonUp                  100       
10                         MS.Internal.JoltHelper.FireEvent                                     896       
11       mscoree3_7.dll                                                                         429164    
12       mscoree3_7.dll                                                                         430528    
13       mscoree3_7.dll                                                                         610803    
14       mscoree3_7.dll                                                                         374593    
15                                                                                              0         
16       agcore.dll        CCoreServices::CLR_FireEvent                                         385       
17       npctrl.dll        CControlBase::ScriptCallback                                         435       
18       npctrl.dll        CXcpDispatcher::OnScriptCallback                                     547       
19       npctrl.dll        CXcpDispatcher::OnReentrancyProtectedWindowMessage                   479"

3 个答案:

答案 0 :(得分:1)

您没有从该堆栈跟踪中获取太多信息。您可以阅读Image名称,该名称是方法所在的程序集的名称,以及Function名称,即该方法的名称。

看起来GeoCaching.Main.btnGoToPin_ClickTransitionStub方法中存在异常,但仅靠堆栈跟踪并不能告诉您异常对象中放置了什么类型的异常或什么信息。

如果您已经使用调试信息编译了应用程序,您将在堆栈跟踪中获得更多信息,例如每种方法中的行号。

答案 1 :(得分:0)

根据提供的信息,您只能在btnGoToPin_Click内获得例外。

要查看真正的源代码,请在该事件处理程序中添加try/catch,最可能的是,您会发现错误。

祝你好运

答案 2 :(得分:0)

如前所述,错误发生在btnGoToPin_Click中 但是应用程序是在发布模式下编译的,这就是为什么你没有完整的堆栈跟踪。

当在发布模式下编译应用程序时,编译器会进行多次优化。 第一个适用于你的情况的是用这种方法的主体替换对小方法的调用。这称为“内联优化”

所以也许你的错误是在btnGoToPin_Click中调用的另一个方法,但由于内联而对堆栈跟踪不可见。

如果您想了解更多关于内联的信息,请访问nice article