行号不正确的堆栈跟踪

发布于 2024-09-01 10:05:16 字数 658 浏览 7 评论 0原文

为什么堆栈跟踪会显示“第 0 行”,但仅针对堆栈跟踪中的一帧

例如。

...
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at My.LibraryA.Some.Method():line 16
at My.LibraryB.Some.OtherMethod():line 0
at My.LibraryB.Some.Method():line 22
at My.LibraryA.Some.Method():line 10

背景

我有一个应用程序因异常而失败,并且正在将堆栈跟踪记录到其日志文件中。构建应用程序时,所有程序集都使用完整的调试信息进行编译(项目属性 -> 构建 -> 高级 -> 调试信息 -> 完整),因此生成了 PDB 文件。为了帮助我诊断错误的来源,我将 PDB 文件放入应用程序的 bin 目录中,并重现了该异常。每个堆栈帧的所有行号看起来都是正确的,但显示“第 0 行”作为其源的行号除外。

Why would a stack trace show "line 0", but only for one frame in the stack trace?

eg.

...
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
at My.LibraryA.Some.Method():line 16
at My.LibraryB.Some.OtherMethod():line 0
at My.LibraryB.Some.Method():line 22
at My.LibraryA.Some.Method():line 10

Background:

I have an application that is failing with an exception, and is logging a stack trace to its log file. When the applciation was built, all assemblies were compiled with full debug info (Project Properties -> Build -> Advanced -> Debug Info -> Full), and so PDB files were generated. To help me diagnose where the error is coming from, I dropped the PDB files into the application's bin directory, and reproduced the exception. All line numbers for each stack frame look correct, with the exception of one which displays "line 0" as its source.

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

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

发布评论

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

评论(1

那请放手 2024-09-08 10:05:16

正如埃里克所建议的,这确实是他们方法的内联。

我设法在本地重现原始错误,但仅限于在发布版本中进行编译时。由于我有 PDB,因此我可以单步执行代码并找到问题。

This was indeed down the the inlining of them method as Eric suggested.

I managed to reproduce the original error locally, but only when compiling in a release build. As I had the PDBs, I could step through the code and find the problem.

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