microsoft / microsoft/microsoft-ui-xaml
UnhandledException when using ResourceDictionary with CustomResource and WindowsAppSDK 1.7.25
- Dominant language
- C++
- Stars
- 8.4k
- Forks
- 942
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 105
Description
### Describe the bug
Custom class defined in xaml constructs new CustomXamlResourceLoader in its static constructor. In xaml the setup is the following:
```xaml
```
In the constructor of `UserThemeResources` we set:
```cs
CustomXamlResourceLoader.Current = new UserThemeResourceLoader();
```
_This builds and runs fine with WindowsAppSDK **1.6.25**._
In 1.7.256 version of SDK we get:
```
{Microsoft.UI.Xaml.UnhandledExceptionEventArgs}
Exception: {"The text associated with this error code could not be found.\r\n\r\nNo custom resource loader set. [Line: 17 Position: 27]"}
```
and also the static constructor of UserThemeResources is not fired at all.
### Steps to reproduce the bug
[UserThemeResources_Test.zip](https://github.com/user-attachments/files/19651603/UserThemeResources_Test.zip)
Run the application with WindowsAppsSDK 1.7.25 restored. Notice the exception
### Expected behavior
No exception and the constructor to fire.
### Screenshots

### NuGet package version
None
### Windows version
Windows 11 (24H2): Build 26100
### Additional context
_No response_
Contributor guide
Research direction
Start with the attached UserThemeResources_Test.zip and reproduce the failure using WindowsAppSDK 1.7.25, then compare the same resource-loading setup with 1.6.25. Inspect the UserThemeResources initialization and CustomXamlResourceLoader.Current entry points shown in the report; done means the resource dictionary loads without an unhandled exception and the loader constructor is reached.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100