【问题标题】:Missing StackTrace Information缺少 StackTrace 信息
【发布时间】:2010-10-11 18:40:20
【问题描述】:

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

at Foo.Bar(DataTable table) in D:\Foo\Bar\authoring\App_Code\FooBar.vb:line 87

堆栈跟踪信息的其余部分在哪里?

编辑:

Web.Config 中的自定义错误设置为关闭,我正在处理捕获的错误,如下所示:

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

堆栈跟踪仍在被截断。

【问题讨论】:

    标签: asp.net vb.net exception


    【解决方案1】:

    确保在 web.config 中将 customErrors 设置为“RemoteOnly”或“Off”以禁用友好错误。

    或者可能堆栈跟踪被重置? (尽管如果是这种情况,您仍然应该看到一些东西)

    将重置您的堆栈跟踪。

    catch(Exception ex) 
    {
       throw ex; 
    }
    

    不会重置您的堆栈跟踪。

    catch(Exception ex) 
    {
       throw; 
    }
    

    编辑:

    ex.StackTrace 获取当前堆栈。堆栈跟踪开始 抛出异常的位置(发生错误)并在捕获异常的当前堆栈帧处结束。所以它正在反转调用堆栈。由于您一发生就写出堆栈跟踪,因此没有机会在调用堆栈中进一步向上。

    根据您正在做的事情,您可以尝试一些事情。

    //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
    

    其中一种方法应该适合你。

    【讨论】:

    • 感谢您的回复,请参阅我的编辑以获取更多信息。非常感谢您能给我的任何帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多