如何解释此 C# 堆栈跟踪? 零行错误

发布于 2024-07-17 08:27:01 字数 800 浏览 4 评论 0原文

我收到“对象引用未设置为对象的实例”错误,日志中堆栈顶部有以下内容(C# ASP.NET 应用程序):

@Web.UI.UserBrochurePage.Page_Load(Object,EventArgs)+25 Line: 0  
@System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr,Object,Object,EventArgs)+0 Line: 0  
@System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object,EventArgs)+26 Line: 0  
@System.Web.UI.Control.OnLoad(EventArgs)+38 Line: 0 
@System.Web.UI.Control.LoadRecursive()+35 Line: 0
@System.Web.UI.Page.ProcessRequestMain(Boolean,Boolean)+1160 Line: 0 

我不明白的事情:

  1. 每个错误都在第 0 行
  2. 最有趣的错误(最上面的错误 - 在我的代码中)后面有一个“+25”。 我从来不明白这些意味着什么,尽管我假设它们是行上的字符偏移量......如果是这样的话,它不会指向任何有意义的东西(参数声明的中间)。

这是处于发布模式的生产系统,但我通常仍然可以从堆栈跟踪对象中获取行号。 不幸的是,在这种情况下,错误不会在我们的调试系统上重现,因此我只能尽力而为。

任何意见,将不胜感激。

谢谢, 汤姆

I'm getting a "Object reference not set to an instance of an object" error with the following at the top of the stack in the logs (C# ASP.NET application):

@Web.UI.UserBrochurePage.Page_Load(Object,EventArgs)+25 Line: 0  
@System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr,Object,Object,EventArgs)+0 Line: 0  
@System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object,EventArgs)+26 Line: 0  
@System.Web.UI.Control.OnLoad(EventArgs)+38 Line: 0 
@System.Web.UI.Control.LoadRecursive()+35 Line: 0
@System.Web.UI.Page.ProcessRequestMain(Boolean,Boolean)+1160 Line: 0 

The things I don't understand:

  1. Every error is on line zero
  2. The most interesting error (top one - in my code) has a "+25" after it. I never understood what those meant, although I assumed they were character offsets on the line... if that were the case, it wouldn't point to anything meaningful (the middle of a parameter declaration).

This is a production system in release mode, but I still can usually get line numbers out of the stack trace objects. In this case, unfortunately, the error does not reproduce on our debug systems, so I'm stuck doing my best with this.

Any advice would be appreciated.

Thanks,
Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

真心难拥有 2024-07-24 08:27:01

我认为您在堆栈跟踪中的每个调用都会看到“第 0 行”,因为您的代码是在发布模式而不是调试模式下编译的。 在调试模式下,您的代码将被编译以包含调试符号文件 (.pdb)。 当此文件可用时,您的异常堆栈跟踪将准确表示行号。

无论如何,只有 Page_Load 的行号是重要的,因为其余的都是框架程序集的内部调用。

每个堆栈跟踪条目后面的 +xx 数字显然是“本机代码的字节偏移量”。 我承认,最初在我看来,这是以滴答声或毫秒为单位的执行时间。

I think that you see "Line 0" for every call in the stacktrace because your code is compiled in Release mode instead of Debug mode. In debug mode, your code will be compiled to include a debug symbols file (.pdb). When this file is available, your exception stacktrace will accurately represent the line numbers.

In any case, only the line number of your Page_Load is significant because the rest are internal calls of the framework assemblies.

The +xx number after each stacktrace entry is apparently the "byte offset into native code". I do confess that it originally appeared to me that it was the time of execution in ticks or milliseconds.

怕倦 2024-07-24 08:27:01

有关了解偏移量的信息,请参阅此问题。 我怀疑你真的应该构建带有调试信息的生产二进制文件 - 这比检查 IL 来找出偏移量意味着哪一行要容易得多。

See this question for information about understanding the offsets. I suspect you should really just build you production binaries with debug information in - it's going to be a lot easier than examining the IL to work out what offset means which line.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文