Hi Chris,
In article <(E-Mail Removed)>, (E-Mail Removed) says...
> The Trace class in the .NET framework provides basic tracing capabilities. I
> would like to create my own tracer that includes the date and time the trace
> occured and what function and class the trace was called from.
>
> The date and time is no problem, the tricky bit is to determine where the
> function was called from, I only want to go one level up, not the whole call
> stack. Is there any way to use reflection to determine the calling function?
> I had a look at the MethodBase class but I can't find any promising
> properties or methods. Since the call stack is used when getting the stack
> trace from an exception and for security checks, I was hoping it would be
> possible to get hold of something I could use.
>
> Chris
>
I'm using this:
private static string GetCallerInfo()
{
StackTrace st = new StackTrace(3);
return st.GetFrame(0).GetMethod().DeclaringType.FullName +
"." + st.GetFrame(0).GetMethod().Name;
}
Sunny
|