How can you get the current class of a method?
We are writting out trace error messages using the
System.Reflecti on.MethodBase.G etCurrentMethod to get the Current
Method but a string is passed telling for the class. I am a newbie to
the .NET but I would think there should be a way to say
GetCurrentClass ?
Here is our code.
=============== ===========
Imports System.Reflecti on.MethodBase
....
Public Class ctlUserMaintena nce : Inherits ctlBaseEdit
....
Protected Overrides Sub InitForm()
mPageName = "User Maintenance"
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArg s)
MyBase.OnLoad(e )
Try
SetDirtyFlag(Fa lse)
InitGrid()
Catch ex As Exception
SendError(ex, GetCurrentMetho d.Name, mPageName)
End Try
End Sub
=============== ===========
The SendError routine displays/logs the error. As you can see
GetCurrentMetho d.Name is used to pass "OnLoad" but mPageName is hard
coded with "User Maintenance". I would like a way to get the Class
name of "ctlUserMainten ance" without having to hard code it. Then I
would be able to tell exactly what class thrown the error.
Any other ideas on how to handle error conditions would be appretiated
too.
It would be really cool if I could get the SendError to open to run
"DevEnv /Edit" and have it open the class that is causing the problem
so I can debug.
Thanks in advance.
We are writting out trace error messages using the
System.Reflecti on.MethodBase.G etCurrentMethod to get the Current
Method but a string is passed telling for the class. I am a newbie to
the .NET but I would think there should be a way to say
GetCurrentClass ?
Here is our code.
=============== ===========
Imports System.Reflecti on.MethodBase
....
Public Class ctlUserMaintena nce : Inherits ctlBaseEdit
....
Protected Overrides Sub InitForm()
mPageName = "User Maintenance"
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArg s)
MyBase.OnLoad(e )
Try
SetDirtyFlag(Fa lse)
InitGrid()
Catch ex As Exception
SendError(ex, GetCurrentMetho d.Name, mPageName)
End Try
End Sub
=============== ===========
The SendError routine displays/logs the error. As you can see
GetCurrentMetho d.Name is used to pass "OnLoad" but mPageName is hard
coded with "User Maintenance". I would like a way to get the Class
name of "ctlUserMainten ance" without having to hard code it. Then I
would be able to tell exactly what class thrown the error.
Any other ideas on how to handle error conditions would be appretiated
too.
It would be really cool if I could get the SendError to open to run
"DevEnv /Edit" and have it open the class that is causing the problem
so I can debug.
Thanks in advance.
Comment