问题
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