>I wrote an ErrorLog class, based on ideas from Kevin McNeish's book. It allows for logging of errors, exceptions and straight messages to an XML log.
>
>I can send a flag to optionally include Exception.StackTrace which I normally turn off as it is too verbose.
>
>One thing I'm looking for, if it exists is the equivalent of VFP's LineNo()
and Program()
to add to the message I create. These I'd need for a straight message, not based on an Exception class.
>
>Is here such an animal in .Net (C#)?I searched the help files and found System.Diagnostics:
StackTrace st = new StackTrace(true);
StackFrame sf = st.GetFrame(0);
Console.WriteLine("Method: {0}",sf.GetMethod());
Console.WriteLine("Line Number: {0}",sf.GetFileLineNumber());
but this code always returns line 0 in a release (production) console exe
If I run it in the debugger, it returns the line number of the StackTrace creation line above.
So it looks like the release version does not include debug info/source code line numbers (at least I don't yet know how), and the debugger does not return the real line number (I have line numbers turned on in the editor).
In some ways VFP is nicer and easier isn't it? <g>