Stack trace with incorrect line number

Posted by adrianbanks on Stack Overflow See other posts from Stack Overflow or by adrianbanks
Published on 2010-05-13T15:08:21Z Indexed on 2010/05/13 15:14 UTC
Read the original article Hit count: 260

Filed under:
|
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET