缺少 Uno App 异常启动 windows.color

Uno App exception launch missing windows.color

我刚刚将我的应用迁移为使用 Uno 4.0,但遇到了一些问题。当我去构建和 运行 项目时-我收到此错误:

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

我确实使用 MaterialColorPaletteOverride.xaml 中的颜色。我目前在 1.0.507 有 Uno.Material。我计划迁移那个 - 但想先解决这个问题。此代码在迁移之前确实有效 - 所以我认为现在以某种方式引用了不同的颜色。

我正在使用以下软件包:

这是我 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>

问题实际上是您使用的 Uno.Material 版本不兼容。 1.0.0.-dev.507 与 Uno.UI 3.x 兼容,但与 4.x 不兼容,因为存在许多重大更改(包括 Windows.UI.Colors 中的更改)。您还需要将 Uno.Material 升级到 4.x 兼容版本以避免此错误。