English 中文(简体)
缺少堆栈跟踪信息
原标题:
  • 时间:2009-03-06 15:24:22
  •  标签:

我似乎在我的堆栈跟踪中缺少一些信息,这是我得到的内容:

at Foo.Bar(DataTable table) in D:FooBarauthoringApp_CodeFooBar.vb:line 87

剩下的堆栈跟踪信息在哪里?

编辑

Web.Config中的自定义错误已关闭,我将在捕获错误时处理它,像这样:

 Catch ex As Exception
     Respose.Write(ex.StackTrace)
 End Try

栈跟踪仍然被截断。

最佳回答

请确保在你的web.config中将customErrors设置为"RemoteOnly"或"Off",以禁用友好错误提示。

或者堆栈追踪被重置了吗? (尽管如果是这种情况,你仍然应该能看到某些东西)

将重置您的堆栈跟踪。

catch(Exception ex) 
{
   throw ex; 
}

不会重置您的堆栈跟踪。

catch(Exception ex) 
{
   throw; 
}

编辑:

ex.StackTrace gets the current stack. The stacktrace starts where the exception was thrown(error happens) and ends at the current stack frame where the exception is caught. So it is reversing the call stack. Since you are writing out stacktrace as soon as it happens it doesn t get a chance to go any further up the callstack.

根据你正在做什么,你可以尝试一些事情。

//To just see the stackTrace
Catch ex As Exception
     Throw
 End Try

Environment.StackTrace - 获取当前堆栈跟踪信息

//If you are trying to log the stacktrace 
Catch ex As Exception
     Respose.Write(Environment.StackTrace)
     Respose.Write(ex.StackTrace)
 End Try

//If is hiding then try - hiding as in throw ex vs just throw
Catch ex As Exception
     //careful innerException can be null
     //so need to check before using it
     Respose.Write(ex.InnerException)
 End Try

其中一种方法应该适用于您。

问题回答

暂无回答




相关问题
热门标签