简体   繁体   English

WPF设计器引发奇怪的错误

[英]WPF designer throwing strange error

This is VS2013 Pro and I'm working on a WPF desktop application. 这是VS2013 Pro,我正在使用WPF桌面应用程序。 The problem I'm facing is that WPF designer throws exception when I move mouse around in the designer window. 我面临的问题是,当我在设计器窗口中四处移动鼠标时,WPF设计器会引发异常。 Here's the stack trace that it shows: 这是它显示的堆栈跟踪:

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()

I attached another Visual Studio instance using help from this SO post and it breaks on the exception, but the entire call stack is external code and I cannot see what's wrong. 我使用此SO帖子中的帮助附加了另一个Visual Studio实例,它打破了异常,但是整个调用堆栈都是外部代码,我看不到出了什么问题。 Anyone else came across this? 还有其他人遇到吗? Is this something I can fix? 我可以解决这个问题吗?

The hint is FrugalStructList . 提示是FrugalStructList In researching that issue the other null reference exceptions occur due to style issues. 在研究该问题时,由于样式问题会发生其他null引用异常。

Plan of attack to narrow down the problem 缩小问题范围的攻击计划

  1. Look at the styles, is there a style which attempts to do a process on a specific data type? 看一下样式,是否有一种样式尝试对特定数据类型进行处理? If it does, is if failing due to being in design mode because null data context is causing the issue? 如果是这样,是否由于处于空模式上下文导致问题而由于处于设计模式而导致失败?
  2. Comment out all controls and add them in one by one til you get the failure to determine the control where the issue resides. 注释掉所有控件,并一一添加它们,直到您无法确定问题所在的控件。 When found does the control handle null dependency values properly? 找到控件后,它是否可以正确处理null依赖项值? If not add more null checks. 如果没有,则添加更多的空检查。
  3. Design mode is special and one still needs to accommodate it with checks around data processing in the back end. 设计模式是特殊的,仍然需要在后端进行围绕数据处理的检查来适应它。 Add (if not) if (!DesignerProperties.IsInDesignModeProperty) above any code which might be trying to process a null value. 如果if (!DesignerProperties.IsInDesignModeProperty)在任何可能尝试处理空值的代码上方添加(如果没有)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM