AvaloniaUI中的XAML补充问题

时间:2020-06-11 18:05:29

标签: avaloniaui

当我向项目添加新的View并尝试构建它时,会发生此错误:

`System.Xaml.XamlException: No precompiled XAML found for Test.Views.SchemesView, make sure to specify x:Class and include your XAML file as AvaloniaResource
17:59:18.882 [Error]  Exception caught by FireAndForget
System.AggregateException: One or more errors occurred. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at AvaloniaVS.Services.PreviewerProcess.<OnMessageAsync>d__37.MoveNext() in D:\a\1\s\AvaloniaVS\Services\PreviewerProcess.cs:line 433
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.NullReferenceException: Object reference not set to an instance of an object.
   at AvaloniaVS.Services.PreviewerProcess.<OnMessageAsync>d__37.MoveNext() in D:\a\1\s\AvaloniaVS\Services\PreviewerProcess.cs:line 433<---
`

如何解决?

1 个答案:

答案 0 :(得分:2)

此错误意味着Avalonia XAML编译器MSBuild任务尚未处理SchemesView的任何XAML。原因可能有以下几种:

  • 您尚未将XAML文件添加为AvaloniaResourceEmbeddedResource
  • x:Class指令丢失或无效
  • 您的项目没有直接引用Avalonia软件包。从0.9.x版本开始,由于与.NET Core 2.1 SDK的兼容性而需要直接引用,该版本缺少对buildTransitive的支持。此限制可能会在0.10中取消。
相关问题