External component has thrown an exception



I seem to get this exception when I open forms using ShowDialog() from
event handlers. Consider the following:

private void cboCombo_SelectedIndexChanged(...)
{
try
{
(do something that raises an exception here)
}
catch(Exception ex)
{
try { (open a form with ShowDialog() here) }
catch {}
}
}

Somehow the SEHException is being thrown to Main() where it crashes the
app. The stack trace is as follows:

at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at
System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32
dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at WinApp.MainForm.Main(String[] args) in mainform.cs:line 2078

I've gotten around this issue in the past by starting a timer in the
event handler, and then launching the form from the timer elapsed
event. That works ok, but gets cumbersome quickly.

I can provide code samples if necessary, but the code in question
really isn't doing anything spectacular. I don't see how the code
sample above could allow an exception to be thrown (without an explicit
throw, that is).

Does anyone have any experience with this issue?

TIA

.



Relevant Pages

  • RE: Problem with Windows Form
    ... My problem was not ShowDialog or Show method. ... This dll it is another company. ... When I change this formulario.Show for ShowDialog, I recieve this exception: ... dwComponentID, Int32 reason, Int32 pvLoopData) ...
    (microsoft.public.vsnet.general)
  • RE: ShowDialog() =?= Dispose()?
    ... It sounds like you have an exception happening while processing the ShowDialog function. ... You stated that the exception stack trace is being shown. ... Phill W. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Exceptions and WinForms
    ... Do you recreate the form before calling ShowDialog again? ... > It appears that exception handling outside of a form corrupts winforms. ... > a button click event which does a showdialogfor form2. ... > exception is thrown in form2 the code correctly arrives back at the catch ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Exceptions and WinForms
    ... VS attached and see if the dialog stays up with no secondary exception. ... > Hi Daniel. ... >>> a button click event which does a showdialog() for form2. ...
    (microsoft.public.dotnet.framework.compactframework)
  • 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)