为什么 wpf 在“System.Windows.ContextLayoutManager.From”中报告 NullReferenceException?

Why does wpf report a NullReferenceException at "System.Windows.ContextLayoutManager.From"?

提问人:sai proactive 提问时间:3/15/2023 最后编辑:Clemenssai proactive 更新时间:3/15/2023 访问量:39

问:

   在 System.Windows.ContextLayoutManager.From(Dispatcher dispatcher)
   在 System.Windows.UIElement.InvalidateMeasure()
   在 System.Windows.Controls.Decorator.set_Child(UIElement value)
   在 System.Windows.Documents.AdornerDecorator.set_Child(UIElement value)
   在 MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
   在 MS.Internal.Xaml.Runtime.PartialTrustTolerantRuntime.SetValue(Object obj, XamlMember property, Object value)
   在 System.Xaml.XamlObjectWriter.Logic_ApplyPropertyValue(ObjectWriterContext ctx, XamlMember prop, Object value, Boolean onParent)
   在 System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentProperty(ObjectWriterContext ctx)
   在 System.Xaml.XamlObjectWriter.Logic_CreateAndAssignToParentStart(ObjectWriterContext ctx)
   在 System.Xaml.XamlObjectWriter.WriteStartMember(XamlMember property)
   在 System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
   在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
   在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri)
   在 System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream)
   在 Main.MainView.InitializeComponent()
......

我阅读了此方法的源代码 ContextLayoutManager.From。 调度程序值只能为 null,但为什么呢?

WPF NullReferenceException 调度程序 InitializeComponent

评论


答: 暂无答案