microsoft / microsoft/WindowsAppSDK
ResourceLoader.GetString throws COMException (NamedResource Not Found) for keys containing '.' in WinUI 3 desktop app
- Dominant language
- C++
- Stars
- 4.7k
- Forks
- 471
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 28
Description
### Describe the bug
When calling:
```cs
var loader = new ResourceLoader();
var value = loader.GetString("XXXXX.Common.Yes");
```
a COMException is thrown:
```
NamedResource Not Found.
```
The resource key does exist in Resources.resw.
If the key is changed from:
```
XXXXX.Common.Yes
```
to:
```
XXXXX_Common_Yes
```
the lookup succeeds immediately.
This indicates that resource keys containing . may not be resolved correctly by ResourceLoader.GetString.
The exception originates from WinRT resource lookup and is reported by Visual Studio at throw time (even if later caught).
API reference:
https://learn.microsoft.com/windows/windows-app-sdk/api/winrt/microsoft.windows.applicationmodel.resources.resourceloader.getstring
https://github.com/microsoft/WindowsAppSDK/blob/main/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ResourceLoader.cpp
### Steps to reproduce the bug
Create a new WinUI 3 Desktop project (C#/C++).
Add a string resource in Resources.resw:
```
Name: XXXXX.Common.Yes
Value: Yes
```
Call:
```cs
var loader = new ResourceLoader();
var value = loader.GetString("XXXXX.Common.Yes");
```
Observe that COMException (NamedResource Not Found) is thrown.
Change the key to:
```
XXXXX_Common_Yes
```
Update the code accordingly and rerun.
Observe that the lookup succeeds.
### Expected behavior
WinUI 3 (via Windows App SDK)
Desktop application
Note: This behavior was observed in a desktop project. Packaged vs. unpackaged scenarios have not been independently verified, so no conclusion is made regarding packaging impact.
### Screenshots
### NuGet package version
Windows App SDK 1.8.5: 1.8.260209005
### Packaging type
Unpackaged
### Windows version
Insider Build (xxxxx)
### IDE
_No response_
### Additional context
Replacing . with _ consistently resolves the issue.
This may relate to URI fragment semantics or MRT/PRI key normalization.
Clarification would be appreciated on whether . is officially supported in resource keys for ResourceLoader.GetString.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the lookup with a dotted and underscored key in an unpackaged WinUI 3 desktop project using Windows App SDK 1.8.5. Read the ResourceLoader.GetString API reference and dev/mrt/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ResourceLoader.cpp; done means establishing whether dotted keys are supported and documenting or correcting the observed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, csharp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100