Search

WPF splash screen dismisses dialog box! by The Dag

Active

22
0
Sign in
to vote
Type: Bug
ID: 600197
Opened: 9/17/2010 4:50:18 AM
Access Restriction: Public
4
Workaround(s)
9
User(s) can reproduce this bug
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 (expand)

Visual Studio/Silverlight/Tooling version

.NET Framework 4

What category (if any) best represents this feedback?

Reliability

Steps to reproduce

1. Create a new WPF app.
2. In the MainWindow constructor, invoke MessageBox.Show.
3. Add an image file to the project, and set it's build action to SplashScreen.
4. Run and behold the strangeness unfold!

My code:

public MainWindow()
{
InitializeComponent();
Debug.WriteLine("{0}", MessageBox.Show("With a splash screen, this messagebox is just automatically dismissed!", "Test", MessageBoxButton.OKCancel));
}

Product Language

English

Operating System

Windows 7

Operating System Language

English

Actual results

Dialog box automatically responds "no" to any question.

Expected results

Dialog box allows the user to respond and returns the corresponding MessageBoxResult.
File Attachments
0 attachments
Sign in to post a comment.
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 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.
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 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 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/