zoukankan      html  css  js  c++  java
  • 程序运行在.Net 4.0低版本上 报“System.NullReferenceException”错误

    因为程序仅在个别机器上出现“ System.NullReferenceException”问题,而在其他机器上一切运行正常,所以认为是环境问题

    具体错误信息如下:

    2018-09-14 10:12:14,355 [1] A77450B89D5443928C58B6A81A3D40B7  - System.NullReferenceException: Object reference not set to an instance of an object.
       at ***.System.Windows.Markup.IStyleConnector.Connect(Int32 connectionId, Object target)
       at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
       at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
       at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
       at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)
       at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory templateRoot, Int32 lastChildIndex, HybridDictionary childIndexFromChildID, FrameworkTemplate frameworkTemplate)
       at System.Windows.FrameworkTemplate.ApplyTemplateContent(UncommonField`1 templateDataField, FrameworkElement container)
       at System.Windows.FrameworkElement.ApplyTemplate()
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Border.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.Control.MeasureOverride(Size constraint)
       at System.Windows.Controls.TreeViewItem.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.Controls.StackPanel.MeasureOverride(Size constraint)
       at System.Windows.FrameworkElement.MeasureCore(Size availableSize)
       at System.Windows.UIElement.Measure(Size availableSize)
       at System.Windows.ContextLayoutManager.UpdateLayout()
       at System.Windows.UIElement.UpdateLayout()
       at System.Windows.Interop.HwndSource.SetLayoutSize()
       at System.Windows.Interop.HwndSource.set_RootVisualInternal(Visual value)
       at System.Windows.Interop.HwndSource.set_RootVisual(Visual value)
       at System.Windows.Window.SetRootVisual()
       at System.Windows.Window.SetRootVisualAndUpdateSTC()
       at System.Windows.Window.SetupInitialState(Double requestedTop, Double requestedLeft, Double requestedWidth, Double requestedHeight)
       at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
       at System.Windows.Window.CreateSourceWindowDuringShow()
       at System.Windows.Window.SafeCreateWindowDuringShow()
       at System.Windows.Window.ShowHelper(Object booleanBox)
       at System.Windows.Window.Show()
    

     问题原因:

          .net 4.0不支持嵌套模板中加入event和style, 必须打补丁。

          参考 https://support.microsoft.com/zh-cn/help/2464222/fix-a-nullreferenceexception-exception-occurs-when-you-run-a-net-frame

     解决方法:

          安装.Net 4.0.3的集成补丁包(KB2464222)或更高补丁如:.Net 4.5。

  • 相关阅读:
    golang 操作json
    CloudFoundry应用部署记录
    Stream流
    学做8位计算机
    无废话技术选型之--消息中间件选型(rabbitMQ、rocketMQ、kafka)
    无废话设计模式(22)行为型模式--解释器模式
    无废话设计模式(21)行为模式--迭代器模式
    无废话设计模式(20)行为型模式--职责链模式
    无废话设计模式(19)行为模式--访问者模式
    无废话设计模式(18)行为型模式--命令模式
  • 原文地址:https://www.cnblogs.com/shenchao/p/9647153.html
Copyright © 2011-2022 走看看