Re: Exception from Managed Component being swallowed in Interop

From: Christian Fröschlin (froeschlin_at_mvtec.com)
Date: 10/06/04


Date: Wed, 06 Oct 2004 10:25:06 +0200

Ian Tompsett wrote:

> That is, my C# is calling VB6 code, which is raising an event caught by C#
> code, which then throws an exception (meant to be caught by the original C#
> code).

AFAIK, errors raised in event handlers for COM
objects are silently ignored by .NET. Note that
it is often not a good idea to raise an error
in an event handler, because it may break the
object which raised the event.

You could mimick the behavior of the original
control by raising an *event* yourself, or you
could set an error flag and throw the exception
later from the method originally called by
the C# application.



Relevant Pages

  • External component has thrown an exception
    ... I seem to get this exception when I open forms using ShowDialog() from ... event handlers. ... at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: debug .net runtime
    ... I do have it break on exception. ... the child relations of a dataset. ... It looks like there may be event handlers ... hooked to the OnCollectionChanging or OnCollectionChanged that are causing ...
    (microsoft.public.dotnet.framework)
  • Re: exception handling in event handlers
    ... We use the same approach for both UI and non-UI eventhandlers. ... > event handlers, we just log the exception. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: customizing validation script-injection error page.
    ... All exceptions can be captured in two places, using event handlers: ... Page object has the Error property ... Your task is to test the class of exception object and redirect to the ... and "Visual Input Security" at http://www.peterblum.com/vise/home.aspx ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Multiple Event Handler Hierarchy
    ... >> AFAIK, yes, except you manipulate the list of handlers. ... > I would say no. AFAIK, the order in which the event handlers are invoked ... > invoked first but personally I wouldn't rely on ...
    (microsoft.public.dotnet.framework.windowsforms)