Exception on Application.Current.Shutdown()

2 posts, 0 answers
  1. Greg
    Greg avatar
    22 posts
    Member since:
    Aug 2011

    Posted 17 Dec 2012 Link to this post

    I'm encountering an exception when I call Application.Current.Shutdown in my app. The exception is:

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

    Stacktrace
    at System.Windows.Window.VerifyNotClosing()
    at System.Windows.Window.InternalClose(Boolean shutdown, Boolean ignoreCancel)
    at System.Windows.Window.Close()
    at Telerik.Windows.Controls.InternalWindow.WindowWithNoChromeWindowHost.Close() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\InternalWindow\WindowWithNoChromeWindowHost.cs:line 54
    at Telerik.Windows.Controls.WindowBase.CloseHostImidiately() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 1333
    at Telerik.Windows.Controls.WindowBase.OnCloseAnimationFinished() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 1025
    at Telerik.Windows.Controls.WindowBase.PlayCloseAnimation() in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 1318
    at Telerik.Windows.Controls.WindowBase.TryClose(Boolean shouldCloseHost) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 719
    at Telerik.Windows.Controls.WindowBase.Telerik.Windows.Controls.InternalWindow.IWindowDragAware.TryClose(Boolean shouldCloseHost) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\WindowBase.cs:line 612
    at Telerik.Windows.Controls.InternalWindow.WindowWithNoChromeWindowHost.OnWindowClosing(Object sender, CancelEventArgs e) in c:\TB\102\WPF_Scrum\Release_WPF\Sources\Development\Controls\Navigation\Window\InternalWindow\WindowWithNoChromeWindowHost.cs:line 277
    at System.Windows.Window.OnClosing(CancelEventArgs e)
    at System.Windows.Window.InternalClose(Boolean shutdown, Boolean ignoreCancel)

    For what it's worth, this app uses Prism and this is a call made via an ICommand on the Shell's viewmodel. As such:

    ShellViewModel.cs (snippet)
    /// <summary>
    /// Gets the exit command.
    /// </summary>
    public ICommand ExitCommand
    {
        get
        {
            return new DelegateCommand(() =>
                {
                    // If we can close, do so...
                    if (this.CanClose)
                    {
                        Application.Current.Shutdown();
                    }
                });
        }
    }

    Without over-complicating matters, the CanClose property is implemented by each screen in the application and will raise a RadWindow dialog prompting for confirmation if there are changes on that screen. Based on our implementation, all of that prompting should be complete before the Application.Current.Shutdown is called so we're not sure what's happening and we can't seem to catch this exception anywhere. It feels like it might be a race condition, but we're not sure where.

    Any ideas?

    Greg
  2. Vladi
    Admin
    Vladi avatar
    744 posts

    Posted 20 Dec 2012 Link to this post

    Hello Greg,

    We are not aware of such issues in the control and we tried to reproduce it but to no avail.

    Could you open a support ticket and send us a project that recreates the issue in order for us to observe it at our side and see what could be the cause of it?

    Kind regards,
    Vladi
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top