WPF设计师抛出奇怪的错误

时间:2015-07-11 19:05:26

标签: .net wpf xaml crash designer

这是VS2013 Pro,我正在研究WPF桌面应用程序。我面临的问题是当我在设计器窗口中移动鼠标时,WPF设计器抛出异常。这是它显示的堆栈跟踪:

System.NullReferenceException
Object reference not set to an instance of an object.
at MS.Utility.FrugalStructList`1.Add(T value)
at System.Windows.Media.PointCollection.CloneCurrentValueCore(Freezable source)
at System.Windows.Freezable.CloneCoreCommon(Freezable sourceFreezable, Boolean useCurrentValue, Boolean cloneFrozenValues)
at System.Windows.Freezable.CloneCurrentValueCore(Freezable sourceFreezable)
at System.Windows.Freezable.CloneCurrentValue()
at System.Windows.Media.PathSegmentCollection.CloneCurrentValueCore(Freezable source)
at System.Windows.Freezable.CloneCoreCommon(Freezable sourceFreezable, Boolean useCurrentValue, Boolean cloneFrozenValues)
at System.Windows.Freezable.CloneCurrentValueCore(Freezable sourceFreezable)
at System.Windows.Freezable.CloneCurrentValue()
at System.Windows.Media.PathFigureCollection.CloneCurrentValueCore(Freezable source)
at System.Windows.Freezable.CloneCoreCommon(Freezable sourceFreezable, Boolean useCurrentValue, Boolean cloneFrozenValues)
at System.Windows.Freezable.CloneCurrentValueCore(Freezable sourceFreezable)
at System.Windows.Freezable.CloneCurrentValue()
at System.Windows.Media.PathGeometry.GetAsPathGeometry()
at System.Windows.Media.GeometryHitTestParameters..ctor(Geometry geometry)
at Microsoft.Expression.XamlPlatform.Views.XamlHitTestHelper.PerformHitTest(HitTestParameters hitTestParameters, HitTestModifier hitTestModifier, InvisibleObjectHitTestModifier invisibleObjectHitTestModifier, ICollection`1 ignoredElements, Boolean stopAfterFirstHit, Boolean skipFullyContainedSelectionInObject, ViewHitTestFilterCallback filterCallback)
at Microsoft.Expression.XamlPlatform.Views.XamlSceneView.GetElementsInRectangle(Rect rectangle, HitTestModifier hitTestModifier, InvisibleObjectHitTestModifier invisibleObjectHitTestModifier, Boolean skipFullyContainedSelectionInObject)
at Microsoft.Expression.XamlPlatform.Views.XamlSceneView.HitElementHelper.GetSelectableElementsInRectangle(Rect rectangle)
at Microsoft.Expression.XamlPlatform.Views.XamlSceneView.GetSelectableElementAtPoint(Point point, SelectionFor3D selectionFor3D, Boolean selectedOnly, Boolean smartInvisiblePanelSelect)
at Microsoft.Expression.DesignSurface.View.SceneView.GetCachedSelectableElementAtPoint(Point point, SelectionFor3D selectionFor3D)
at Microsoft.Expression.DesignSurface.Tools.Selection.ElementEditorBehavior.OnHoverOverNonAdorner(Point pointerPosition)
at Microsoft.Expression.DesignSurface.Tools.ElementToolBehavior.OnHover(Point pointerPosition)
at Microsoft.Expression.DesignSurface.Tools.EventRouter.ScopeElement_MouseMove_Internal(MouseEventArgs args)
at Microsoft.Expression.DesignSurface.Tools.EventRouter.ThrottledEventHandler`1.HandleEventNow()
at Microsoft.Expression.DesignSurface.Tools.EventRouter.ThrottledEventHandler`1.ScheduleEventHandling(Args args, Double interval)
at Microsoft.Expression.DesignSurface.Tools.EventRouter.ScopeElement_MouseMove(Object sender, MouseEventArgs args)
at System.Windows.Input.MouseEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run(Window window)
at System.Windows.Application.Run()
at Microsoft.Expression.DesignHost.Isolation.DesignerProcess.RunApplication()
at Microsoft.Expression.DesignHost.Isolation.DesignerProcess.<>c__DisplayClass2.<Main>b__0()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

我使用来自this SO post的帮助附加了另一个Visual Studio实例,它打破了异常,但整个调用堆栈是外部代码,我看不出有什么问题。有人遇到过这个吗?这是我能解决的问题吗?

1 个答案:

答案 0 :(得分:0)

提示为FrugalStructList。在研究该问题时,由于样式问题而发生其他空引用异常。

缩小问题范围的攻击计划

  1. 看看样式,是否有尝试的风格 对特定数据类型进行处理?如果是这样,是否因为处于设计模式而失败,因为空数据上下文导致了问题?
  2. 注释掉所有控件并逐个添加它们,直到您无法确定问题所在的控件。找到时控件是否正确处理空依赖值?如果没有添加更多空检查。
  3. 设计模式很特殊,仍然需要通过后端数据处理检查来适应它。在任何可能尝试处理空值的代码上方添加(如果不是)if (!DesignerProperties.IsInDesignModeProperty)