Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Equivalent of VFP's LineNo() and Program() ?
Message
De
24/05/2005 08:06:01
 
 
À
24/05/2005 07:26:52
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 1.1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Divers
Thread ID:
01017003
Message ID:
01017009
Vues:
25
>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>


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform