Home Dashboard Directory Help
Search

WPF splash screen dismisses dialog box! by The Dag


Status: 

Closed
 as Won't Fix Help for as Won't Fix


28
0
Sign in
to vote
Type: Bug
ID: 600197
Opened: 9/17/2010 4:50:18 AM
Access Restriction: Public
5
Workaround(s)
view
9
User(s) can reproduce this bug

Description

If a dialog box is shown using MessageBox.Show at application startup, but the app has a WPF splash screen (an image with build action set to SplashScreen), the disappearing splashscreen also dismisses the dialog box, causing Show to return MessageBoxResult.No.

The behavior is the same if the dialog is invoked in an event handler for Application.Startup, or if Applictation.OnStartup is overridden - i.e. with base.OnStartup(); MessageBox.Show(...);

On a related note: If MessageBox.Show is invoked in the App constructor, the main window never appears at all (with or without a splash screen). The process remains alive but it's UI never appears.

I'm sorry if I've posted this in the wrong place. I saw products listed for WWF and WCF, but not for WPF, so this was the most specific I saw.
Details
Sign in to post a comment.
Posted by Microsoft on 11/15/2012 at 2:30 PM
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.

We appreciate the feedback. However, this issue will not be addressed in the next version of WPF. Thank you.
–WPF Team.
Posted by XHEO INC on 8/9/2011 at 6:06 PM
This is not isolated to MessageBox calls. It applies to any window using the ShowDialog method.
Posted by Dean Thrasher on 3/16/2011 at 9:08 AM
This item appears to be similar to a previous Microsoft Connect issue: https://connect.microsoft.com/VisualStudio/feedback/details/381980/wpf-splashscreen-closes-messagebox

That item was closed with a status of "Won't Fix." I hope this item won't get closed in the same way.

There are lots of situations that call for a MessageBox or other modal dialog to appear prior to opening the main window of an application. We perform prerequisite checks when our application opens, for example. We also use third-party licensing code that uses modal dialogs to show evaluation / trial messages.

We can't do either of these things in conjunction with the current SplashScreen method implementation.
Posted by Microsoft on 9/19/2010 at 6:48 PM
Thanks for your feedback.

We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by Microsoft on 9/18/2010 at 2:10 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)
Sign in to post a workaround.
Posted by alainbryden on 6/1/2012 at 10:10 AM
Works every time:

    Window temp = new Window() { Visibility=Visibility.Hidden };
    temp.Show();
    MessageBox.Show(temp, "An error occurred before the application could start.\n\nTechnical Details: " + ex.Message, "Fatal Error", MessageBoxButton.OK, MessageBoxImage.Stop);
    App.Current.Shutdown(1);
Posted by Dean Thrasher on 3/16/2011 at 9:16 AM
It's a hack, but you can create a hidden, non-modal window to act as a parent for your MessageBox or modal dialog.

This approach is described here:
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/116bcd83-93bf-42f3-9bfe-da9e7de37546/
Posted by Dean Thrasher on 3/16/2011 at 9:11 AM
You can reimplement your message windows as non-modal dialogs, as described in the answer to this StackOverflow question:

http://stackoverflow.com/questions/3891719/messagebox-with-exception-details-immediately-disappears-if-use-splash-screen-in
Posted by steve_gray on 9/30/2010 at 3:38 AM
I just added a second message box. In my case the message box was in a catch block in my main window ctor, which now looks like this:
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                MessageBox.Show(ex.ToString());
            }
Only the first one disappears.
Posted by The Dag on 9/17/2010 at 4:53 AM
Suggested by Bob Bao, MSFT, in MSDN subscriber support:

Make use of another splash screen implementation, such as the one found at http://www.codeproject.com/KB/WPF/WPFsplashscreen.aspx.