dotnet / dotnet/wpf

[Bug] In the WPF project with a SplashScreen, the first MessageBox.Show in the App's OnStartup method always fails

Open
#10,067 13 comments 0 reactions 0 assignees View on GitHub
Investigate
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

### Description

In the WPF project with a SplashScreen, the first MessageBox.Show in the App's OnStartup method always fails (the display disappears for 0.3 seconds or so and returns No, which does not block the thread).
No matter how long it sleeps before that, It always fails the first time.
```C#
public partial class App
{
private void OnStartup(object sender, StartupEventArgs e)
{
System.Threading.Thread.Sleep(15000); // No matter how long or 0, The SplashScreen stays displayed when sleeping
//At this point the startup image starts to fade and disappear
var result = System.Windows.MessageBox.Show("The first use always automatically disappears and returns No");
Debug.WriteLine($"The first use always returns no test: {result}");
var result2 = System.Windows.MessageBox.Show("Subsequent normal use test, click OK to close");
Debug.WriteLine($"Subsequent normal use test: {result2}");
var result3 = System.Windows.MessageBox.Show("Subsequent normal use test, click OK to close");
Debug.WriteLine($"Subsequent normal use test: {result3}");

System.Windows.MessageBox.Show("Blocking for log replication");
}
}
```
debugging log:
```log
“WpfApp1.exe”(CoreCLR: DefaultDomain): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Private.CoreLib.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Users\MNDIA\source\repos\WpfApp1\bin\Debug\net8.0-windows\WpfApp1.dll”。已加载符号。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\PresentationFramework.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\WindowsBase.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\System.Xaml.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“d:\coder\vs2022\common7\ide\commonextensions\microsoft\hotreload\Microsoft.Extensions.DotNetDeltaApplier.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.IO.Pipes.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Linq.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Collections.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Console.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Threading.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.InteropServices.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Threading.Overlapped.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Security.AccessControl.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Security.Principal.Windows.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Security.Claims.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.Loader.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“D:\Coder\VS2022\Common7\IDE\PrivateAssemblies\Runtime\Microsoft.VisualStudio.Debugger.Runtime.NetCoreApp.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\netstandard.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Threading.ThreadPool.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Diagnostics.TraceSource.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Collections.Concurrent.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Text.RegularExpressions.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Memory.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\Microsoft.Win32.Primitives.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\Microsoft.Win32.Registry.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Collections.Specialized.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\zh-Hans\WindowsBase.resources.dll”。模块已生成,不包含符号。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.ComponentModel.Primitives.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Threading.Thread.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\System.Configuration.ConfigurationManager.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Private.Uri.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Xml.ReaderWriter.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Private.Xml.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Net.WebClient.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Text.Encoding.Extensions.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
单步执行: 正在逐过程执行非用户代码“WpfApp1.App..ctor”
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\System.IO.Packaging.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\PresentationCore.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.10\DirectWriteForwarder.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.Extensions.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Diagnostics.Debug.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.CompilerServices.VisualC.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“d:\coder\vs2022\common7\ide\commonextensions\microsoft\xamldiagnostics\Core\x64\Microsoft.VisualStudio.DesignTools.WpfTap.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Diagnostics.Tracing.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Collections.NonGeneric.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Threading.Tasks.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
单步执行: 正在逐过程执行非用户代码“WpfApp1.App.InitializeComponent”
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.ObjectModel.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.ComponentModel.TypeConverter.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.ComponentModel.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.Serialization.Json.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Private.DataContractSerialization.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.Serialization.Xml.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Runtime.Serialization.Primitives.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Resources.ResourceManager.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Reflection.Emit.ILGeneration.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Reflection.Emit.Lightweight.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Reflection.Primitives.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
线程 '[线程已销毁]' (6096) 已退出,返回值为 0 (0x0)。
“WpfApp1.exe”(CoreCLR: clrhost): 已加载“C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.10\System.Diagnostics.Process.dll”。已跳过加载符号。模块进行了优化,并且调试器选项“仅我的代码”已启用。
The first use always returns no test: No
线程 '[线程已销毁]' (17268) 已退出,返回值为 0 (0x0)。
线程 '[线程已销毁]' (6004) 已退出,返回值为 0 (0x0)。
线程 '[线程已销毁]' (11372) 已退出,返回值为 0 (0x0)。
线程 '[线程已销毁]' (29948) 已退出,返回值为 0 (0x0)。
Subsequent normal use test: OK
Subsequent normal use test: OK

```

### Reproduction Steps

New WPF Project with .NET 8.0 Using OnStartup in App.xaml

### Expected behavior

The first messagebox should block the threads

### Actual behavior

In the WPF project with a SplashScreen, the first MessageBox.Show in the App's OnStartup method always fails (the display disappears for 0.3 seconds or so and returns No, which does not block the thread). This does not convey interactive information

### Regression?

.NET CORE3.1 does not have a SplashScreen.

### Known Workarounds

_No response_

### Impact

_No response_

### Configuration

_No response_

### Other information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.