Sorry Alex. I thought you were talking only about exceptions that were caught or thrown. My bad. I don't know any way of getting line numbers like you want (doesn't mean you can't ... just means that I haven't needed to research it myself).
BTW, I knew that you had a console app and that a Console.WriteLine would have been more appropriate in the code that I posted, but I just cut/paste some stuff I had. I figured you'd know the difference between MessageBox and Console methods. <g>
~~Bonnie
>
>Hey Alex,
>>
>>The StackTrace is useful, but I don't think you've used it correctly. Try the StackTrace property of the Exception that got thrown. IOW, something like this:
>>>>catch (Exception ex)
>>{
>> MessageBox.Show(ex.Message + (char)13 +
>> ex.StackTrace.ToString());
>>}
>>
>>In debug mode it will give you the correct line number.
>>
>>~~Bonnie>
>Yes, I understand and I use that. But the app I'm building you may remember, is a console app with no UI. So I write Exceptions and events to an XML log. I do not like to use the Windows EventLog and prefer to keep my own XML file in the same dir as the EXE for this app.
>
>When I have an Exception it works fine. The question arises when I want to just log an event or a warning. I want to add my own messaging to at strategic points. I'd like to add the line number to those messages (there is no exception object there).
>
>As I mentioned I found that the debugger includes line numbers but the release exe does not so it always shows zero. At least I haven't found a switch for it. In VFP it's on by default unless you want to strip debug info from the exe. That's my point.
>
>Thx.