Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / May 2005

Tip: Looking for answers? Try searching our database.

automatically Debug.WriteLine whenever function or event is triggered

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thomasamillergoogle@yahoo.com - 22 May 2005 01:10 GMT
I have hundreds of events/functions in my windows app. now they look
like this

private void muHowlNow_Click(object sender, EventArgs e)
{
 Debug.WriteLine("HowlNow was clicked");
 this.Label1.Text = "wow";
 //do some stuff
}
I am tired of having to put Debug.WriteLine("HowlNow was clicked");
every time. Is there a way (through reflection or some other magic) to
have it Debug.Writeline the function name automatically?

This will make life easier, and also when I obfuscate my code later it
will make it more difficult for a cracker to understand.
Franco Gustavo - 22 May 2005 08:11 GMT
// create the stack frame for the function that called this function
StackFrame sf = new StackFrame( 1, true );

// save the method name
string methodName = sf.GetMethod().ToString();

// save the file name
string fileName = sf.GetFileName();

// save the line number
int lineNumber = sf.GetFileLineNumber();

Gustavo.

>I have hundreds of events/functions in my windows app. now they look
> like this
[quoted text clipped - 11 lines]
> This will make life easier, and also when I obfuscate my code later it
> will make it more difficult for a cracker to understand.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.