A
Arthur Dent
Hello all...
I have a component which i wrote, which is used for automatically emailing
errors, so that when an app (usually a website) goes into production, i
automatically get emailed about any exceptions which occur on the site. A
friend wanted to use the same thing but have the ability to override the
OnError action, because their mail handler had to be handled in an unusual
manner.
To accomodate his need, i added a delegate definition to the component. Now
it allows the user to either accept the intrinsic behaviour or replace it
with their own... for an odd email handler, or logging or simply
messageboxing the user.
The only problem is now i cannot drag the component onto a form designer
anymore, because it says the Handler property is not serializable.
Is there any way that i can get around that? Isnt a delegate basically a
function pointer? which is basically an Int? which should be serializable?
My code (partial/relevant) is as follows:
===== BEGIN CODE ==============================================
Public Class ErrorHandler
Inherits System.ComponentModel.Component
Delegate Sub ExceptionHandler(ByVal ex As Exception, ByVal OneTimeExtra
As String)
Private pHandler As ExceptionHandler = AddressOf PrivateHandler
Public Property Handler() As ExceptionHandler
Get
Return pHandler
End Get
Set(ByVal Value As ExceptionHandler)
If Value Is Nothing Then _
pHandler = AddressOf PrivateHandler _
Else _
pHandler = Value
End Set
End Property
Private Sub PrivateHandler(ByVal ex As Exception, ByVal OneTimeExtra As
String)
..... <intrinsic handling>
End Sub
End Class
===== END CODE ================================================
Thanks in advance,
- Arthur Dent.
I have a component which i wrote, which is used for automatically emailing
errors, so that when an app (usually a website) goes into production, i
automatically get emailed about any exceptions which occur on the site. A
friend wanted to use the same thing but have the ability to override the
OnError action, because their mail handler had to be handled in an unusual
manner.
To accomodate his need, i added a delegate definition to the component. Now
it allows the user to either accept the intrinsic behaviour or replace it
with their own... for an odd email handler, or logging or simply
messageboxing the user.
The only problem is now i cannot drag the component onto a form designer
anymore, because it says the Handler property is not serializable.
Is there any way that i can get around that? Isnt a delegate basically a
function pointer? which is basically an Int? which should be serializable?
My code (partial/relevant) is as follows:
===== BEGIN CODE ==============================================
Public Class ErrorHandler
Inherits System.ComponentModel.Component
Delegate Sub ExceptionHandler(ByVal ex As Exception, ByVal OneTimeExtra
As String)
Private pHandler As ExceptionHandler = AddressOf PrivateHandler
Public Property Handler() As ExceptionHandler
Get
Return pHandler
End Get
Set(ByVal Value As ExceptionHandler)
If Value Is Nothing Then _
pHandler = AddressOf PrivateHandler _
Else _
pHandler = Value
End Set
End Property
Private Sub PrivateHandler(ByVal ex As Exception, ByVal OneTimeExtra As
String)
..... <intrinsic handling>
End Sub
End Class
===== END CODE ================================================
Thanks in advance,
- Arthur Dent.