Jim,
you can get the class name using:
Me.GetType().ToString
(ofcourse, assuming you are calling this from an instance method; in a
shared method, Me would be nothing so you won't be able to do the above)
to get the currently executing method, you can do:
MethodBase.GetCurrentMethod()
this returns a MethodBase object from which you can then retrieve the name,
parameters, etc of the method. I haven't tried this one but I think this
should work.
hope this helps..
Imran.
"Jim Bancroft" <bo********@nowhere.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi all,
I'm writing an exception handler for one of my VB.Net methods and
wondered how best to dynamically put the class and method name in my
message string.
My code looks like this currently:
Catch ex as Exception
Dim ex1 As New Exception("Error encountered in
Class-- MyClass, Method-- MyMethod", ex)
Throw ex1
Obviously, hardcoding the class and method names isn't such a hot
idea. I assume reflection will help pull the right information, however
I'm new to that subject and wondered if someone could help provide a code
snippet for this, or a link to where I can learn more? Thanks!
-Jim