microsoft / microsoft/WindowsAppSDK

Invalid resourcekey generates unhelpful winrt::hresult_error exception

Open
#5,442 1 comment 0 reactions 0 assignees View on GitHub
area-MRTCore needs-triage
Dominant language
C++
Stars
4.7k
Forks
471
Avg merge
3d 13h
Merged PRs (30d)
28

Description

### Describe the bug

If I create a custom control and in the generic.xaml template and accidentially use a static resource that doesn't exist, I'm met with an extremely unhelpful error message:

![Image](https://github.com/user-attachments/assets/7edea092-61f0-47a6-ab17-f0fafe5269f5)

### Steps to reproduce the bug

1. Open the following project: [ChatApp.zip](https://github.com/user-attachments/files/20357655/ChatApp.zip)
2. Run the application and observe the exception

The exception is happening because in `\Themes\Generic.xaml` an invalid static resource in line 56 is used. The error message does nothing to help lead me to this error message. In many other cases, the error message will include the xaml line number and resource key name, but in this case a really bad crash occurs.

This is another one of the death-by-1000-razorcut issues that can significantly slow down the inner developer loop. Having more actionable errors will greatly improve the developer experience.

### Expected behavior

A helpful error message that helps identify my typo and unblock me.

### Screenshots

_No response_

### NuGet package version

Windows App SDK 1.8 Experimental 2: 1.8.250515001-experimental2

### Packaging type

Packaged (MSIX)

### Windows version

Windows 11 version 24H2 (22621, October 2024 Update)

### IDE

Visual Studio 2022

### Additional context

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Open the attached ChatApp project and inspect \Themes\Generic.xaml at line 56, where the invalid static resource is used. Reproduce the crash under Windows App SDK 1.8 Experimental 2 and trace the resulting winrt::hresult_error; done means the missing resource produces an actionable error identifying the typo or resource key and relevant XAML location.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
desktop
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.