By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 915 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

Attribute Based Programming - Tracing

P: n/a
Ken
I'm interested in building a component that will be used to trace an
application with minimal coding. The applications we build are typically we
applications. The trace and debug classes offer some of this functionality,
but I'm looking for something that a little cleaner to impliment. I've come
across several articles discussing Aspect Oriented Programming techiniques,
which in .net appear to require inheritiing from ContextBoundObject. This
idea is very appealing, in that by applying several custom attributes to a
class I can capture method names and the parameters being passed in only by
applying attributes at run time. The down side is that each class needs to
inherit from ContextBoundObject, which severly limits my ability to inheret
from anything else.

Does anyone have any alternative ideas that would allow me to inspect the
values of parameters being passed into a method at run time? The key piece
here is that our application are typically web apps.
Mar 20 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

I use reflection:

public static void log(string s)
{

StackTrace stackTrace = new StackTrace();
StackFrame stackFrame = stackTrace.GetFrame(1);
MethodBase methodBase = stackFrame.GetMethod();

Trace.WriteLine(DateTime.Now+":"+methodBase.Name+" :"+s);
}

Ken wrote:
I'm interested in building a component that will be used to trace an
application with minimal coding. The applications we build are typically we
applications. The trace and debug classes offer some of this functionality,
but I'm looking for something that a little cleaner to impliment. I've come
across several articles discussing Aspect Oriented Programming techiniques,
which in .net appear to require inheritiing from ContextBoundObject. This
idea is very appealing, in that by applying several custom attributes to a
class I can capture method names and the parameters being passed in only by
applying attributes at run time. The down side is that each class needs to
inherit from ContextBoundObject, which severly limits my ability to inheret
from anything else.

Does anyone have any alternative ideas that would allow me to inspect the
values of parameters being passed into a method at run time? The key piece
here is that our application are typically web apps.

--
Get the new
http://www.you-read-it-here-first.com
content from Texeme Textcasting Technology
Mar 21 '06 #2

P: n/a
Ken
John,

Thanks for the suggestion. This allows me to easily get the method name. I
was wanting to capture the method name and any parameter values being passed
into the method. I haven't found any ways to do that.

Ken

"John Bailo" wrote:

I use reflection:

public static void log(string s)
{

StackTrace stackTrace = new StackTrace();
StackFrame stackFrame = stackTrace.GetFrame(1);
MethodBase methodBase = stackFrame.GetMethod();

Trace.WriteLine(DateTime.Now+":"+methodBase.Name+" :"+s);
}

Ken wrote:
I'm interested in building a component that will be used to trace an
application with minimal coding. The applications we build are typically we
applications. The trace and debug classes offer some of this functionality,
but I'm looking for something that a little cleaner to impliment. I've come
across several articles discussing Aspect Oriented Programming techiniques,
which in .net appear to require inheritiing from ContextBoundObject. This
idea is very appealing, in that by applying several custom attributes to a
class I can capture method names and the parameters being passed in only by
applying attributes at run time. The down side is that each class needs to
inherit from ContextBoundObject, which severly limits my ability to inheret
from anything else.

Does anyone have any alternative ideas that would allow me to inspect the
values of parameters being passed into a method at run time? The key piece
here is that our application are typically web apps.

--
Get the new
http://www.you-read-it-here-first.com
content from Texeme Textcasting Technology

Mar 22 '06 #3

P: n/a

Use ParameterInfo class.

It's the next level down from MethodBase information

Ken wrote:
John,

Thanks for the suggestion. This allows me to easily get the method name. I
was wanting to capture the method name and any parameter values being passed
into the method. I haven't found any ways to do that.

Ken

"John Bailo" wrote:

I use reflection:

public static void log(string s)
{

StackTrace stackTrace = new StackTrace();
StackFrame stackFrame = stackTrace.GetFrame(1);
MethodBase methodBase = stackFrame.GetMethod();

Trace.WriteLine(DateTime.Now+":"+methodBase.Name+" :"+s);
}

Ken wrote:
I'm interested in building a component that will be used to trace an
application with minimal coding. The applications we build are typically we
applications. The trace and debug classes offer some of this functionality,
but I'm looking for something that a little cleaner to impliment. I've come
across several articles discussing Aspect Oriented Programming techiniques,
which in .net appear to require inheritiing from ContextBoundObject. This
idea is very appealing, in that by applying several custom attributes to a
class I can capture method names and the parameters being passed in only by
applying attributes at run time. The down side is that each class needs to
inherit from ContextBoundObject, which severly limits my ability to inheret
from anything else.

Does anyone have any alternative ideas that would allow me to inspect the
values of parameters being passed into a method at run time? The key piece
here is that our application are typically web apps.

--
Get the new
http://www.you-read-it-here-first.com
content from Texeme Textcasting Technology

--
Get the new
http://www.you-read-it-here-first.com
content from Texeme Textcasting Technology
Mar 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.