Search code examples
uno-platform

Uno App exception launch missing windows.color


I just migrated my app to use Uno 4.0 and am having a few issues. When I go to build and run the project- I am getting this error:

System.MissingFieldException Message=Field not found: Windows.UI.Color Windows.UI.Colors.Black Due to: Could not find field in class

I do use the colors in my MaterialColorPaletteOverride.xaml. I currently have Uno.Material at 1.0.507. I plan to migrate that- but would like to resolve this issue first. This code did work before the migration- so I think somehow the colors are referenced differently now.

I am using the following packages:

  • Uno.Core 4.0.1
  • Uno.Material 1.0.0.-dev.507
  • Uno.UI 4.0.7
  • Microsoft.UI.Xaml 2.7.0

Here is my snippet from my MaterialColorPaletteOverride.xaml:

    <ResourceDictionary
       xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
       xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
       xmlns:local="using:NeatApp.Shared">
           <ResourceDictionary.ThemeDictionaries>
           <!-- Light Theme -->
           <ResourceDictionary x:Key="Light">
               <SolidColorBrush x:Key="MaterialOnBackgroundBrush" Color="Black"/>
           </ResourceDictionary>
           <!-- Dark Theme -->
           <ResourceDictionary x:Key="Dark">
               <SolidColorBrush x:Key="MaterialOnBackgroundBrush" Color="White"/>
           </ResourceDictionary>
       </ResourceDictionary.ThemeDictionaries>    
    </ResourceDictionary>

Solution

  • The problem is actually that you are using an incompatible version of Uno.Material. 1.0.0.-dev.507 is compatible with Uno.UI 3.x, but not with 4.x, due to the fact that there were many breaking changes (including changes in Windows.UI.Colors). You will also need to upgrade Uno.Material to a 4.x compatible version to avoid this error.