473,385 Members | 1,341 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Attribute Based Programming - Tracing

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
3 1320

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

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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Coral Snake | last post by:
I am having problems with programming even simple "Hello World" programs from books and tutorials that use Python GUI libraries. Such Programs cause python to throw "Attribute Errors" even when the...
22
by: Rich | last post by:
I am trying to create a site that will re-direct a user based on their OS. For this site I will need to send NT4 and 95 users to site A and 2000/XP users to site B. All others should be directed...
2
by: deepukutty | last post by:
Hi all, I know tht we can do tracing in two ways.one in application level and the other is at Page level. I am able to see the details of trace either on the page itself or .../trace.axd page....
0
by: cnys | last post by:
We have an ASP.NET 2.0 (C#) app and we're trying to add tracing into it. The tracing functionality within .NET is great, but when we output this to a file, it's kind of sparse. So, we're looking...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.