D
Dan
Hi all!
When I throw my custom Exception class the first time in my code, the
compiler takes a lot of time for find the following catch
EX:
try
Throw New MyCustomException("test")
Catch exx As MyCustomException
MessageBox.Show(exx.Message)
Catch ex As Exception
Me.HandleException(ex)
End Try
Thanks for answers !!
Dan
----------------------------------
Here is my custom exception class :
<Serializable()> _
Public Class MyCustomException : Inherits
System.ApplicationException
'Internal storage of the LayerName custom property
Private m_LayerName As String = ""
'For new exception instance with default property values
Public Sub New()
MyBase.New()
End Sub
'For new exception instance with specified message
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
'For new exception instance with specified message and
LayerName
Public Sub New(ByVal message As String, ByVal LayerName As
String)
MyBase.New(message)
m_LayerName = LayerName
End Sub
'For new exception instance with specified message and inner
exception
Public Sub New(ByVal message As String, ByVal innerException As
Exception)
MyBase.New(message, innerException)
End Sub
'For new exception instance with specified message, inner
exception and LayerName
Public Sub New(ByVal message As String, ByVal innerException As
Exception, ByVal LayerName As String)
MyBase.New(message, innerException)
m_LayerName = LayerName
End Sub
'To re-materialize exception and custom property at the
receiving end
Protected Sub New(ByVal info As SerializationInfo, _
ByVal context As StreamingContext)
MyBase.New(info, context)
m_LayerName = info.GetString("LayerName")
End Sub
'To de-materialize exception and custom property at the sending
end
Public Overrides Sub GetObjectData(ByVal info As
SerializationInfo, _
ByVal
context As StreamingContext)
MyBase.GetObjectData(info, context)
info.AddValue("LayerName", m_LayerName)
End Sub
'To add custom property to standard exception message
Public Overrides ReadOnly Property Message() As String
Get
Return MyBase.Message & Environment.NewLine & "Layer
name: " & m_LayerName
End Get
End Property
'LayerName property, to help exception consumers
ReadOnly Property LayerName() As String
Get
LayerName = m_LayerName
End Get
End Property
End Class
When I throw my custom Exception class the first time in my code, the
compiler takes a lot of time for find the following catch
EX:
try
Throw New MyCustomException("test")
Catch exx As MyCustomException
MessageBox.Show(exx.Message)
Catch ex As Exception
Me.HandleException(ex)
End Try
Thanks for answers !!
Dan
----------------------------------
Here is my custom exception class :
<Serializable()> _
Public Class MyCustomException : Inherits
System.ApplicationException
'Internal storage of the LayerName custom property
Private m_LayerName As String = ""
'For new exception instance with default property values
Public Sub New()
MyBase.New()
End Sub
'For new exception instance with specified message
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
'For new exception instance with specified message and
LayerName
Public Sub New(ByVal message As String, ByVal LayerName As
String)
MyBase.New(message)
m_LayerName = LayerName
End Sub
'For new exception instance with specified message and inner
exception
Public Sub New(ByVal message As String, ByVal innerException As
Exception)
MyBase.New(message, innerException)
End Sub
'For new exception instance with specified message, inner
exception and LayerName
Public Sub New(ByVal message As String, ByVal innerException As
Exception, ByVal LayerName As String)
MyBase.New(message, innerException)
m_LayerName = LayerName
End Sub
'To re-materialize exception and custom property at the
receiving end
Protected Sub New(ByVal info As SerializationInfo, _
ByVal context As StreamingContext)
MyBase.New(info, context)
m_LayerName = info.GetString("LayerName")
End Sub
'To de-materialize exception and custom property at the sending
end
Public Overrides Sub GetObjectData(ByVal info As
SerializationInfo, _
ByVal
context As StreamingContext)
MyBase.GetObjectData(info, context)
info.AddValue("LayerName", m_LayerName)
End Sub
'To add custom property to standard exception message
Public Overrides ReadOnly Property Message() As String
Get
Return MyBase.Message & Environment.NewLine & "Layer
name: " & m_LayerName
End Get
End Property
'LayerName property, to help exception consumers
ReadOnly Property LayerName() As String
Get
LayerName = m_LayerName
End Get
End Property
End Class