dotNET
dotNET

Reputation: 35400

WPF designer throwing strange error

This is VS2013 Pro and I'm working on a WPF desktop application. The problem I'm facing is that WPF designer throws exception when I move mouse around in the designer window. 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. Anyone else came across this? Is this something I can fix?

Upvotes: 1

Views: 286

Answers (1)

ΩmegaMan
ΩmegaMan

Reputation: 31596

The hint is FrugalStructList. In researching that issue the other null reference exceptions occur due to style issues.

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? 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.

Upvotes: 1

Related Questions