G
gman
How can you get the current class of a method?
We are writting out trace error messages using the
System.Reflection.MethodBase.GetCurrentMethod 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.Reflection.MethodBase
....
Public Class ctlUserMaintenance : Inherits ctlBaseEdit
....
Protected Overrides Sub InitForm()
mPageName = "User Maintenance"
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Try
SetDirtyFlag(False)
InitGrid()
Catch ex As Exception
SendError(ex, GetCurrentMethod.Name, mPageName)
End Try
End Sub
==========================
The SendError routine displays/logs the error. As you can see
GetCurrentMethod.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 "ctlUserMaintenance" 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.Reflection.MethodBase.GetCurrentMethod 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.Reflection.MethodBase
....
Public Class ctlUserMaintenance : Inherits ctlBaseEdit
....
Protected Overrides Sub InitForm()
mPageName = "User Maintenance"
End Sub
Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
MyBase.OnLoad(e)
Try
SetDirtyFlag(False)
InitGrid()
Catch ex As Exception
SendError(ex, GetCurrentMethod.Name, mPageName)
End Try
End Sub
==========================
The SendError routine displays/logs the error. As you can see
GetCurrentMethod.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 "ctlUserMaintenance" 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.