Window Closing Issue

Jun 24, 2011 at 1:51 PM

Hey Sacha,

I've had a bizarre issue lately, and it only occurs on rare occasion so I've been hard-pressed to localize it and determine the proximate cause.  I just recently started using the Cinch WPFMessageBoxService and WPFUIVisualizerService, and I'm wondering if this is something you've run across or had issue with.

The exception I'm getting has the following message:

Cannot set Visibility to Visible or call Show, ShowDialog, Close, or WindowInteropHelper.EnsureHandle while a Window is closing.

With a Stack Trace of:

at System.Windows.Window.VerifyNotClosing() at System.Windows.Window.InternalClose(Boolean shutdown, Boolean ignoreCancel) at System.Windows.Application.DoShutdown() at System.Windows.Application.ShutdownImpl() at System.Windows.Application.ShutdownCallback(Object arg) at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

It may have absolutely nothing to do with Cinch, but if it did, I thought perhaps it would be something you might have run across previously.  Typically I get this exception if I'm trying to show a window that's already closed or something but that isn't the case here, this only occurs when the application is being closed.  I'm catching the unhandled exception and emailing it to myself so I don't have to rely on my users to report it, but when I look at my users who run into this issue, they're using disparate portions of the application, so I thought it might be more systematic than a specific block of code.

Any ideas?

Thank you!

Aj


Coordinator
Jun 25, 2011 at 8:40 AM

Weird.

 

Have to say I have never seen any exception like that before in all my Cinch development/using time, and we use both the WPFMessageBoxService and WPFUIVisualizerService at work on a very very large WPF project. Honestly can say I have never seen your Exception before. So on this occasion I am sorry to say I don't think I can offer much help.

Jan 6, 2012 at 1:30 PM

Just in case anyone ever runs across this issue, I finally tracked it down...actually one of the other developers at my office did. 

We have a few dozen non-modal windows that open from our main window, each of which prompt for save if changes have been made.  If a save dialog is open and the user shuts down the main window, since our app is set to shut down on main window close, the existing open dialogs get orphaned when their corresponding non-modal windows get shut down by the application.  Doesn't happen particularly often as you can tell based on the date the last time it happened, but it's good to have finally found the underlying issue.

Aj

Coordinator
Jan 29, 2012 at 9:26 AM

Cool, glad you tracked it down, sounds like a hard one to find