StackFrame GetFileName and GetFileLineNumber empty - sometimes

L

Lord Bah

I've seen some other posts referring to this problem, but didn't find
any solutions.

We're trying to log a call stack when we have a problem, using the
StackTrace and StackFrame classes in C#. They are created via new
StackTrace(true) to get the debugging info and trace.GetFrame(i). Our
classes are all compiled Debug. What we find is, even though the IDE
debugger knows the line numbers of all the methods, when we walk the
stack trace in our code, some of our methods' frames have GetFileName()
returning null and GetFileLineNumber() returning zero. Yet for other
frames it knows both values.

What would prevent these fields from being filled in for an assembly
built Debug?

How does the debugger know the line number when StackTrace doesn't?
 
L

Lord Bah

The frames which don't have the line number filled in belong to a type
which has some properties and methods marked [CLSCompliant(false)],
although none of those are actually on the stack at this time. Would
the presence of that attribute anywhere in the type prevent
StackTrace/StackFrame from getting line number information for any
method in that type?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top