行号不正确的堆栈跟踪
为什么堆栈跟踪会显示“第 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如埃里克所建议的,这确实是他们方法的内联。
我设法在本地重现原始错误,但仅限于在发布版本中进行编译时。由于我有 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.