From: Lcubed on
I have timed dialogs that work great, except when there is another
window on top and the window that is not on top wants to close. Then a
System.ArgumentException occurs with the message "An error message
cannot be displayed because an optional resource assembly containing
it cannot be found" I'm not missing any assemblies, if the dialog is
on top, it closes fine.

Can anyone decipher this?

Here is the C# code where the exception occurs:

private System.Windows.Forms.Timer timerClose;
// ....
void tCloseDiag_tick(object sender, EventArgs e)
{
try
{
timerClose.Enabled = false;
this.DialogResult = DialogResult.Cancel;
}
catch (Exception ex)
{
// exception here
}
}

Any suggestions appreciated.
From: "Paul G. Tobey [eMVP]" p space tobey no spam AT no instrument no spam DOT on
So, you have potentially stacked-up dialogs where the middle ones in the
stack may closed as a result of a time-out? That seems like a poor design,
but maybe you could notify all child forms that they should close via some
structure that you come up with and, when they've all done so, set the
DialogResult.

Paul T.

"Lcubed" <loris.emailbox(a)gmail.com> wrote in message
news:e4d9a959-fe1c-4431-a1eb-ef1d69353238(a)l5g2000yqo.googlegroups.com...
>I have timed dialogs that work great, except when there is another
> window on top and the window that is not on top wants to close. Then a
> System.ArgumentException occurs with the message "An error message
> cannot be displayed because an optional resource assembly containing
> it cannot be found" I'm not missing any assemblies, if the dialog is
> on top, it closes fine.
>
> Can anyone decipher this?
>
> Here is the C# code where the exception occurs:
>
> private System.Windows.Forms.Timer timerClose;
> // ....
> void tCloseDiag_tick(object sender, EventArgs e)
> {
> try
> {
> timerClose.Enabled = false;
> this.DialogResult = DialogResult.Cancel;
> }
> catch (Exception ex)
> {
> // exception here
> }
> }
>
> Any suggestions appreciated.


From: Lcubed on
It's not as bad as all that. There's just one dialog that needs to
close and once in a blue moon another dialog is on top of it. But the
top dialog needs to be there. I have tried making the offending dialog
the TopMost right before closing, but this does not work either.
However, that does answer my question, a dialog must be on top to
close, so I need to do something else.

Thanks!


On Aug 26, 5:22 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
> So, you have potentially stacked-up dialogs where the middle ones in the
> stack may closed as a result of a time-out?  That seems like a poor design,
> but maybe you could notify all child forms that they should close via some
> structure that you come up with and, when they've all done so, set the
> DialogResult.
>
> Paul T.
>
> "Lcubed" <loris.email...(a)gmail.com> wrote in message
>
> news:e4d9a959-fe1c-4431-a1eb-ef1d69353238(a)l5g2000yqo.googlegroups.com...
>
> >I have timed dialogs that work great, except when there is another
> > window on top and the window that is not on top wants to close. Then a
> > System.ArgumentException occurs with the message "An error message
> > cannot be displayed because an optional resource assembly containing
> > it cannot be found"  I'm not missing any assemblies, if the dialog is
> > on top, it closes fine.
>
> > Can anyone decipher this?
>
> > Here is the C# code where the exception occurs:
>
> >        private System.Windows.Forms.Timer  timerClose;
> >        // ....
> >        void tCloseDiag_tick(object sender, EventArgs e)
> >        {
> >            try
> >            {
> >                timerClose.Enabled = false;
> >                this.DialogResult = DialogResult.Cancel;
> >            }
> >            catch (Exception ex)
> >            {
> >                // exception here
> >            }
> >        }
>
> > Any suggestions appreciated.

From: "Paul G. Tobey [eMVP]" p space tobey no spam AT no instrument no spam DOT on
And it's a child of the one you're trying to close? Perhaps that's an area
that could be done another way. I would guess that, since you're trying to
close the parent of an active window without closing that window, you're
establishing a condition where the child does something via a reference to
the parent that no longer contains sensible data, causing the exception.

TopMost has nothing to do with parent-child relationships. I would guess
that a dialog does not need to be "on top" of the window ordering to close,
but I bet it can't be disabled and waiting for a child dialog of its own to
close when it goes away.

Paul T.

"Lcubed" <loris.emailbox(a)gmail.com> wrote in message
news:39531cc9-37de-45b7-a380-b52304a338ba(a)e34g2000vbm.googlegroups.com...
It's not as bad as all that. There's just one dialog that needs to
close and once in a blue moon another dialog is on top of it. But the
top dialog needs to be there. I have tried making the offending dialog
the TopMost right before closing, but this does not work either.
However, that does answer my question, a dialog must be on top to
close, so I need to do something else.

Thanks!


On Aug 26, 5:22 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
> So, you have potentially stacked-up dialogs where the middle ones in the
> stack may closed as a result of a time-out? That seems like a poor design,
> but maybe you could notify all child forms that they should close via some
> structure that you come up with and, when they've all done so, set the
> DialogResult.
>
> Paul T.
>
> "Lcubed" <loris.email...(a)gmail.com> wrote in message
>
> news:e4d9a959-fe1c-4431-a1eb-ef1d69353238(a)l5g2000yqo.googlegroups.com...
>
> >I have timed dialogs that work great, except when there is another
> > window on top and the window that is not on top wants to close. Then a
> > System.ArgumentException occurs with the message "An error message
> > cannot be displayed because an optional resource assembly containing
> > it cannot be found" I'm not missing any assemblies, if the dialog is
> > on top, it closes fine.
>
> > Can anyone decipher this?
>
> > Here is the C# code where the exception occurs:
>
> > private System.Windows.Forms.Timer timerClose;
> > // ....
> > void tCloseDiag_tick(object sender, EventArgs e)
> > {
> > try
> > {
> > timerClose.Enabled = false;
> > this.DialogResult = DialogResult.Cancel;
> > }
> > catch (Exception ex)
> > {
> > // exception here
> > }
> > }
>
> > Any suggestions appreciated.


From: Lcubed on
No, I'm not trying to close the parent of a child. The parent for both
is the main dialog which I keep open for the duration of the app. It's
just an unrelated sibling :-) trying to close. It doesn't sound like
that is illegal. I've had other apps do the same thing. If an
unrelated window that is not on top tries to close, there is an
exception. I was hoping there might be something I'm missing.

On Aug 26, 5:44 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
no instrument no spam DOT com> wrote:
> And it's a child of the one you're trying to close?  Perhaps that's an area
> that could be done another way.  I would guess that, since you're trying to
> close the parent of an active window without closing that window, you're
> establishing a condition where the child does something via a reference to
> the parent that no longer contains sensible data, causing the exception.
>
> TopMost has nothing to do with parent-child relationships.  I would guess
> that a dialog does not need to be "on top" of the window ordering to close,
> but I bet it can't be disabled and waiting for a child dialog of its own to
> close when it goes away.
>
> Paul T.
>
> "Lcubed" <loris.email...(a)gmail.com> wrote in message
>
> news:39531cc9-37de-45b7-a380-b52304a338ba(a)e34g2000vbm.googlegroups.com...
> It's not as bad as all that. There's just one dialog that needs to
> close and once in a blue moon another dialog is on top of it. But the
> top dialog needs to be there. I have tried making the offending dialog
> the TopMost right before closing, but this does not work either.
> However, that does answer my question, a dialog must be on top to
> close, so I need to do something else.
>
> Thanks!
>
> On Aug 26, 5:22 pm, "Paul G. Tobey [eMVP]" <p space tobey no spam AT
> no instrument no spam DOT com> wrote:
>
> > So, you have potentially stacked-up dialogs where the middle ones in the
> > stack may closed as a result of a time-out? That seems like a poor design,
> > but maybe you could notify all child forms that they should close via some
> > structure that you come up with and, when they've all done so, set the
> > DialogResult.
>
> > Paul T.
>
> > "Lcubed" <loris.email...(a)gmail.com> wrote in message
>
> >news:e4d9a959-fe1c-4431-a1eb-ef1d69353238(a)l5g2000yqo.googlegroups.com...
>
> > >I have timed dialogs that work great, except when there is another
> > > window on top and the window that is not on top wants to close. Then a
> > > System.ArgumentException occurs with the message "An error message
> > > cannot be displayed because an optional resource assembly containing
> > > it cannot be found" I'm not missing any assemblies, if the dialog is
> > > on top, it closes fine.
>
> > > Can anyone decipher this?
>
> > > Here is the C# code where the exception occurs:
>
> > > private System.Windows.Forms.Timer timerClose;
> > > // ....
> > > void tCloseDiag_tick(object sender, EventArgs e)
> > > {
> > > try
> > > {
> > > timerClose.Enabled = false;
> > > this.DialogResult = DialogResult.Cancel;
> > > }
> > > catch (Exception ex)
> > > {
> > > // exception here
> > > }
> > > }
>
> > > Any suggestions appreciated.