Home All Groups Group Topic Archive Search About

StackFrame debug information

Author
15 Jul 2006 2:26 AM
newscorrespondent
I have compiled in DEBUG mode but don't get the debug information from
StackFrame class. Is there a specific setting I need to use so that
information is included for a debug build.

Thanks
Tom

Author
15 Jul 2006 5:26 AM
Barry Kelly
newscorrespond***@charter.net wrote:

> I have compiled in DEBUG mode but don't get the debug information from
> StackFrame class. Is there a specific setting I need to use so that
> information is included for a debug build.

How are you using it? StackFrame is usually used with StackTrace, and it
isn't sensitive to DEBUG (although some inlining may occur at runtime
when compiled in Release mode). To get file information, you must always
create a PDB and distribute it - but it isn't necessary to use full
debugging. Perhaps you aren't using the StackTrace constructor which
takes the boolean argument to collect file information?

Example:

---8<---
using System;
using System.Diagnostics;

class App
{
    static void Main()
    {
        StackFrame frame = new StackTrace(true).GetFrame(0);
        Console.WriteLine("{0} ({1})", frame.GetFileName(),
                                       frame.GetFileLineNumber());
    }
}
--->8---

Compiled with:

---8<---
csc -debug:pdbonly -optimize+ Test.cs
--->8---

When run, it produces this output on my machine:

---8<---
c:\proj\Test\Test.cs (8)
--->8---

-- Barry

Author
15 Jul 2006 12:18 PM
newscorrespondent
Thanks, I missed the true argument.

AddThis Social Bookmark Button