?
Solved

COM event handler does not raise Exceptions that terminate the application

Posted on 2008-10-02
1
Medium Priority
?
264 Views
Last Modified: 2013-12-17
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
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

Open in new window

0
Comment
Question by:Ignacio Soler Garcia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
Ignacio Soler Garcia earned 0 total points
ID: 22768496
The solution to this question is explained here

http://www.codinghorror.com/blog/archives/000216.html

Exceptions rised in threads created outside the CLR are ignored.
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question