PC Review


Reply
Thread Tools Rate Thread

automatically Debug.WriteLine whenever function or event is triggered

 
 
thomasamillergoogle@yahoo.com
Guest
Posts: n/a
 
      22nd May 2005
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.

 
Reply With Quote
 
 
 
 
Franco Gustavo
Guest
Posts: n/a
 
      22nd May 2005
// 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.

<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>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.
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Debug.WriteLine and Trace.WriteLine Bob S Microsoft C# .NET 2 23rd Oct 2007 04:35 AM
debug.writeline where does it go? Lloyd Sheen Microsoft VB .NET 4 27th Aug 2007 09:35 PM
Console.WriteLine vs. Debug.WriteLine formatting Zytan Microsoft C# .NET 1 27th Feb 2007 03:24 AM
Debug.WriteLine and Trace.WriteLine from class. xxx@hotmail.com Microsoft ASP .NET 0 1st Sep 2005 03:24 PM
TextChanged event is not triggered when the text is changed automatically Steve Pan Microsoft ASP .NET 1 6th Nov 2003 02:55 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:41 PM.