Solved

COM event handler does not raise Exceptions that terminate the application

Posted on 2008-10-02
1
242 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
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Having just graduated from college and entered the workforce, I don’t find myself always using the tools and programs I grew accustomed to over the past four years. However, there is one program I continually find myself reverting back to…R.   So …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The viewer will learn how to implement Singleton Design Pattern in Java.
This video teaches viewers about errors in exception handling.

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now