Stack trace with incorrect line number

ぐ巨炮叔叔 提交于 2019-11-30 05:15:26

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/2827856/stack-trace-with-incorrect-line-number

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!