PC Review Forums Newsgroups Microsoft DotNet Microsoft Dot NET Framework automatically Debug.WriteLine whenever function or event is triggered

Reply

automatically Debug.WriteLine whenever function or event is triggered

 
Thread Tools Rate Thread
Old 22-05-2005, 02:10 AM   #1
thomasamillergoogle@yahoo.com
Guest
 
Posts: n/a
Default automatically Debug.WriteLine whenever function or event is triggered


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
Old 22-05-2005, 09:11 AM   #2
Franco Gustavo
Guest
 
Posts: n/a
Default Re: automatically Debug.WriteLine whenever function or event is triggered

// 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.

<thomasamillergoogle@yahoo.com> wrote in message
news:1116720646.610582.253910@z14g2000cwz.googlegroups.com...
>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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off