Ignacio Soler Garcia
asked on
COM event handler does not raise Exceptions that terminate the application
I have an VB.Net application that has to use a COM object. That COM has an object that raises events that I process.
If inside the eventhandler I make a Throw New Exception() (or an Exception happens) the eventhandler exists (that's the expected behaviour) but nothing more happens. No unhandled exception eventhandlers catch the exception not the application ends with the tipical Unexpected Exception.
The Debuger shows that the COM eventhandler is executing at the main thread if this helps.
As an example you see this code. Executing this produces no result at all, its like it has not been executed
If inside the eventhandler I make a Throw New Exception() (or an Exception happens) the eventhandler exists (that's the expected behaviour) but nothing more happens. No unhandled exception eventhandlers catch the exception not the application ends with the tipical Unexpected Exception.
The Debuger shows that the COM eventhandler is executing at the main thread if this helps.
As an example you see this code. Executing this produces no result at all, its like it has not been executed
Private Sub DataChange(ByVal eventIdentifier As Integer, ByVal itemsChanged As Integer, ByRef clientHandlesArray As System.Array, ByRef valuesArray As System.Array, ByRef qualities As System.Array, ByRef timeStamps As System.Array) Handles m_mainGroup.DataChange
Dim index As Integer
Throw New Exception() ' To see what happens
For index = 1 To itemsChanged
Me.OnItemChanged(m_itemListByHandler.Item(DirectCast(clientHandlesArray.GetValue(index), Integer)).ItemID, valuesArray.GetValue(index))
Next
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.