>> Is there some generic property that will give me the name of a function
>> within its catch block?
>
> You can use the StackTrace class - but don't start building stack
> traces in performance critical code.
What about this: ?
http://msdn2.microsoft.com/en-us/library/system.reflection.methodbase.getcurrent
method.aspx
Are there any performance issues with that...?

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
Arne Vajhøj - 09 Sep 2007 00:42 GMT
>>> Is there some generic property that will give me the name of a function
>>> within its catch block?
[quoted text clipped - 6 lines]
>
> Are there any performance issues with that...?
It is in System.Slow namespace, so with sufficient many calls
it could be a performance problem.
It is probably faster than StackTrace though.
Arne
Arne Vajhøj - 17 Sep 2007 01:16 GMT
>>>> Is there some generic property that will give me the name of a function
>>>> within its catch block?
[quoted text clipped - 11 lines]
>
> It is probably faster than StackTrace though.
I made a small test with:
StackTrace
GetCurrentMethod
maintaining a special call stack via AspectDNG
The timings were:
StackTrace: 10,53125
GetCurrentMethod: 2,171875
AOP: 4,171875
So GetCurrentMethod is absolutely the fastest.
But I would say its usability is limited because it does exactly
what its name says so it can only be used in inline code not
out in a special log/whatever method.
Arne
Jon Skeet [C# MVP] - 09 Sep 2007 07:12 GMT
> What about this: ?
> http://msdn2.microsoft.com/en-us/library/system.reflection.methodbase
> .getcurrentmethod.aspx
>
> Are there any performance issues with that...?
Not sure, to be honest - I only didn't mention it because I missed it
:)

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too