microsoft / WindowsAppSDK

The Windows App SDK empowers all Windows desktop apps with modern Windows UI, APIs, and platform features, including back-compat support, shipped via NuGet.
https://docs.microsoft.com/windows/apps/windows-app-sdk/
MIT License
3.85k stars 323 forks source link

1.6 Preview 1: Breaks resource lookups from referenced libraries using full resource paths. Exception: 'ResourceMap Not Found'. #4669

Closed AdriaanLarcai closed 2 months ago

AdriaanLarcai commented 3 months ago

Describe the bug

Apps that reference libraries or library projects that contain either resx or resw resource files can no longer do resource lookups using their full paths. Resource lookups via ResourceLoader.GetForViewIndependentUse() and passing a resource path such as "App1Library/Resources" throw the following exception:

image

System.Runtime.InteropServices.COMException HResult=0x80073B1F Message=ResourceMap Not Found.

ResourceMap Not Found.

Source=WinRT.Runtime StackTrace: at WinRT.ExceptionHelpers.g__Throw|38_0(Int32 hr) at ABI.Windows.ApplicationModel.Resources.IResourceLoaderStatics2Methods.GetForViewIndependentUse(IObjectReference _obj, String name) at Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse(String name)

This exception was originally thrown at this call stack: WinRT.ExceptionHelpers.ThrowExceptionForHR.__Throw|38_0(int) ABI.Windows.ApplicationModel.Resources.IResourceLoaderStatics2Methods.GetForViewIndependentUse(WinRT.IObjectReference, string) Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse(string) AIForged.Helpers.ResourceExtensions.GetLocalized(string, string) in Tools.ResourceExtensions.cs

This even affects controls from vendors such as Syncfusion.

Steps to reproduce the bug

  1. Create a WinUI 3 class library with WindowsAppSDK 1.6 Preview 1 and call it App1Library. 1.1 Add a resource (resx or resw) file and add some strings to it.

  2. Create a WinUI 3 desktop app with WindowsAppSDK 1.6 Preview 1. 2.1 Add a reference to App1Library 2.2 Attempt to retrieve a resource via ResourceLoader.GetForViewIndependentUse() using the full resource path such as "App1Library/Resources".

Expected behavior

This worked in 1.5 and earlier versions.

Screenshots

image

NuGet package version

Windows App SDK 1.6 Preview 1: 1.6.240807006-preview1

Packaging type

Packaged (MSIX), Unpackaged

Windows version

Windows 11 version 22H2 (22621, 2022 Update)

IDE

Visual Studio 2022

Additional context

No response

codendone commented 2 months ago

Potentially the same as, or related to, #4649.

codendone commented 2 months ago

This should be fixed with the change for #4649. Please let us know if you still repro this with 1.6-preview2.