UWP:使用Windows.Desktop目标设备系列触发XamlParseException-找不到画笔

时间:2019-06-06 11:32:31

标签: windows xaml uwp enterprise windows-community-toolkit

Package.appxmanifest文件中进行了以下更改:

之前:

...
<Dependencies>
  <TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
...
<Capabilities>
  <Capability Name="internetClient" />
</Capabilities>

之后:

...
<Dependencies>
  <TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
...
<Capabilities>
  <Capability Name="internetClient" />
  <rescap:Capability Name="extendedBackgroundTaskTime" />
  <rescap:Capability Name="extendedExecutionUnconstrained" />
</Capabilities>

此外,按照本文的规定,引入了一些App.xaml.cs逻辑来处理扩展执行(这对问题没有影响,因为删除它不会改变结果):

https://blogs.msdn.microsoft.com/mvpawardprogram/2018/01/30/non-suspending-uwp-desktop-apps/

在运行应用程序之前没有产生错误,但是在进行了上述更改之后,打开页面时它突然崩溃了:

Windows.UI.Xaml.Markup.XamlParseException
  HResult=0x802B000A
  Message=The text associated with this error code could not be found.

Cannot find a Resource with the Name/Key SystemControlBackgroundChromeBlackLowBrush [Line: 193 Position: 121]
  Source=Windows
  StackTrace:
   at Windows.UI.Xaml.Application.LoadComponent(Object component, Uri resourceLocator, ComponentResourceLocation componentResourceLocation)
   at ...EventsView.InitializeComponent() in ..Client\Application.UWP\obj\x86\Debug\Views\EventsView.g.i.cs:line 43
   at ..EventsView..ctor() in Client\Application.UWP\Views\EventsView.xaml.cs:line 25

第43行的EventsView.xaml.g.i.cs:

global::Windows.UI.Xaml.Application.LoadComponent(this, resourceLocator, global::Windows.UI.Xaml.Controls.Primitives.ComponentResourceLocation.Application);

第25行的EventsView.cs:

<DataTemplate x:Key="FooViewModelDetailsDataTemplate" x:DataType="viewmodels:FooViewModel">

我不确定将应用程序目标设备系列更改为Windows.Desktop会如何突然导致应用程序无法找到特定笔刷。

我已经删除了XAML和视图模型中的所有(所有画笔)显式画笔分配,但是错误仍然存​​在。

在代码库的任何地方,也没有(也没有)使用名称SystemControlBackgroundChromeBlackLowBrush的任何代码行。

0 个答案:

没有答案