Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dotnet-sdk-9.0.100-preview.7.24352.8] WPF apps launch failed with exception 'Value cannot be null. (Parameter 'key')' #9353

Open
Junjun-zhao opened this issue Jul 5, 2024 · 0 comments
Assignees
Labels
Investigate Requires further investigation by the WPF team.

Comments

@Junjun-zhao
Copy link
Member

Junjun-zhao commented Jul 5, 2024

Description

When run the 3rd party application with the latest .NET 9 build "dotnet-sdk-9.0.100-preview.7.24352.8", it failed to launch with exception: 'Value cannot be null. (Parameter 'key')'.

Reproduction Steps

App Repro steps:

  1. Open C:\ReproApps\wpfui\Wpf.Ui.Gallery.runtimeconfig.json file (Please refer to the App location and repro machine info from devdiv bug).
  2. Change the "Wpf.Ui.Gallery.runtimeconfig.json" file to let the app run against with dotnet-sdk-dotnet-sdk-9.0.100-preview.7.24352.8.
"frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.7.24352.1"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.7.24352.1"
      }
    ],
  1. Launch Wpf.Ui.Gallery.exe.

Expected behavior

Launch successfully.

Actual behavior

Launch failed.
Open Event Viewer, we can see below detailed stack trace message:

Application: Wpf.Ui.Gallery.exe
CoreCLR Version: 9.0.24.35201
.NET Version: 9.0.0-preview.7.24352.1
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Windows.Markup.XamlParseException: Set property 'Wpf.Ui.Markup.ThemesDictionary.Theme' threw an exception.
 ---> System.ArgumentNullException: Value cannot be null. (Parameter 'key')
   at System.Collections.Generic.Dictionary`2.FindValue(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at System.Windows.DeferredResourceReferenceList.Get(Object resourceKey)
   at System.Windows.ResourceDictionary.ClearWithoutLock()
   at System.Windows.ResourceDictionary.Clear()
   at System.Windows.ResourceDictionary.set_Source(Uri value)
   at Wpf.Ui.Markup.ThemesDictionary.SetSourceBasedOnSelectedTheme(Nullable`1 selectedApplicationTheme)
   at Wpf.Ui.Markup.ThemesDictionary.set_Theme(ApplicationTheme value)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
   at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
   --- End of inner exception stack trace ---
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, IXamlLineInfo lineInfo, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   at System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   at System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at Wpf.Ui.Gallery.App.InitializeComponent() in C:\Users\v-gwei\Downloads\wpfui-main\wpfui-main\src\Wpf.Ui.Gallery\App.xaml:line 1
   at Wpf.Ui.Gallery.App.Main()

Regression?

Yes
Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.6.24328.19: Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24352.8: Fail
3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24353.17: Fail

Known Workarounds

No response

Impact

No response

Configuration

Application Name: wpfui, Open-SD-WebUI-Launcher, Text-Grab
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-preview.7.24352.8
App or App installer checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2114834
Github Link:
https://github.com/lepoco/wpfui
https://github.com/Ray-Source-X/Open-SD-WebUI-Launcher
https://github.com/TheJoeFin/Text-Grab

Dotnet Info:

.NET SDK:
 Version:           9.0.100-preview.7.24352.8
 Commit:            707091200d
 Workload version:  9.0.100-manifests.82c210e1
 MSBuild version:   17.12.0-preview-24352-02+47393a047

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-preview.7.24352.8\

Host:
  Version:      9.0.0-preview.7.24352.1
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  9.0.100-preview.7.24352.8 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-preview.7.24329.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.7.24352.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.7.24352.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other information

Debug Repro steps:
1.Open "C:\ReproAppSource\wpfui\Wpf.Ui.sln" with Visual Studio.
2. Build the solution.
3. Update bin\Debug\net8.0-windows10.0.22621.0\Wpf.Ui.Gallery.runtimeconfig.json to run against with dotnet-sdk-9.0.100-preview.7.24352.8:

"frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.7.24352.1"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.7.24352.1"
      }
    ]
  1. Press F5 to start the app.

Expected Result:
App launch successful in Visual Studio.

Actual Result:
App launch failed with exception thrown in Visual Studio.
image

Findings:
1.The issue occurs when loading resource xaml file. In below repro app, we tried remove all content in Light.xaml file and only keep below 1 StaticResource, the problem still occurs.

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Color x:Key="AcrylicBackgroundFillColorDefault">#F9F9F9</Color>
    <SolidColorBrush x:Key="ToolTipBackground" Color="{StaticResource AcrylicBackgroundFillColorDefault}" />
</ResourceDictionary>
  1. We found this issue and [dotnet-sdk-9.0.100-preview.7.24352.8] WPF apps launch failed with System.Windows.Markup.XamlParseException #9354 are all related to load Resource in WPF applications. But they have different stack trace and exception message.

@dotnet-actwx-bot @dotnet/compat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

2 participants