View Issue Details

IDProjectCategoryView StatusLast Update
0004330NoesisGUIUnitypublic2025-08-06 13:00
ReporterRisingSunStudios Assigned Tosfernandez  
PrioritynormalSeverityminor 
Status resolvedResolutionno change required 
Product Version3.2 
Target Version3.2.9 
Summary0004330: Application Resources dictionary is empty
Description

I have the following method to retrieve a brush from the application resources. The brush I want to retrieve is inside of Theme.Brushes.Primary.xaml.

        private Brush GetBrush(string brushKey)
        {
            var resourceDictionary = Noesis.GUI.GetApplicationResources();
            if (resourceDictionary.Contains(brushKey))
                return resourceDictionary[brushKey] as Brush;

            throw new ArgumentException($"{brushKey} not found in resource dictionary.");
        }

if I put a breakpoint after the first line, the resourceDictionary has 0 keys and the exception is always hit.
The NoesisSettings has Theme.PrimaryDark xaml file assigned as the Application Resources, which in turn has Theme.Brushes.Primary.xaml included in its merged dictionaries.

When I inspect the application resource dictionary, it has all the correct merged dictionaries, but I would expect their keys to be accessible within the resource dictionary returned by GetApplicationResources()

PlatformWindows

Activities

RisingSunStudios

RisingSunStudios

2025-08-04 21:09

reporter   ~0010954

I just found this thread, seems like it's desired behavior, just need to iterate the merged dictionaries, feel free to close this - I don't think i can do that!
https://www.noesisengine.com/forums/viewtopic.php?t=3043

Thanks

sfernandez

sfernandez

2025-08-05 11:10

manager   ~0010956

Hi,

The expected behavior of a ResourceDictionary is that Contains and [] will search inside merged dictionaries too.
I just did a small test and I'm able to find resources defined in merged dictionaries of the application resources by doing:

ResourceDictionary app = Noesis.GUI.GetApplicationResources();
if (app.Contains("Font.Family.Default"))
{
  object resource = app["Font.Family.Default"];
  if (resource != null)
  {
    ...
  }
}

This code works with our default NoesisTheme.DarkBlue.xaml set as the Application Resources. The resource "Font.Family.Default" is defined in the merged dictionary NoesisTheme.Fonts.xaml.

Are you able to reproduce your problem in a small project and share it here?

jsantos

jsantos

2025-08-05 12:38

manager   ~0010957

Last edited: 2025-08-05 12:38

If this is in Editor mode, make sure you don't interact with Noesis until the first Editor update. Before that, Noesis is probably not initialized.

RisingSunStudios

RisingSunStudios

2025-08-05 14:56

reporter   ~0010958

Last edited: 2025-08-05 14:59

So I just reverted my code back to not iterate the merged dictionaries and now it is working as expected. The keys I was searching for were new additions to the xaml file, so all I can think is that the xaml file wasn't imported until after I changed the code to iterate the merged dictionaries, even though it was 100% saved and I'm positive I would see the "xaml file loaded" message in the unity logs. But all seems fine now, sorry for the false alarm!

For reference, this was being run during runtime.

jsantos

jsantos

2025-08-06 13:00

manager   ~0010961

Thanks. Please reopen if you see this again.

Issue History

Date Modified Username Field Change
2025-08-04 20:57 RisingSunStudios New Issue
2025-08-04 20:58 RisingSunStudios Description Updated
2025-08-04 21:05 RisingSunStudios Severity block => minor
2025-08-04 21:09 RisingSunStudios Note Added: 0010954
2025-08-05 11:10 sfernandez Assigned To => sfernandez
2025-08-05 11:10 sfernandez Status new => feedback
2025-08-05 11:10 sfernandez Note Added: 0010956
2025-08-05 12:37 jsantos Target Version => 3.2.9
2025-08-05 12:38 jsantos Note Added: 0010957
2025-08-05 12:38 jsantos Note Edited: 0010957
2025-08-05 14:56 RisingSunStudios Note Added: 0010958
2025-08-05 14:56 RisingSunStudios Status feedback => assigned
2025-08-05 14:56 RisingSunStudios Note Edited: 0010958
2025-08-05 14:57 RisingSunStudios Note Edited: 0010958
2025-08-05 14:59 RisingSunStudios Note Edited: 0010958
2025-08-06 13:00 jsantos Status assigned => resolved
2025-08-06 13:00 jsantos Resolution open => no change required
2025-08-06 13:00 jsantos Note Added: 0010961
2025-10-10 13:29 jsantos Category Unity3D => Unity