Solved

COM event handler does not raise Exceptions that terminate the application

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

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Visual Studio npm 1 29
VB.net/VSTO Excel Add-in 2 19
Stop Git from being my repository 1 26
How can I add google maps in vb.net. 2 22
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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

726 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