Getting an ArgumentException when howering mouse over the popup


This exception is getting swallowed somewhere, but it is quite irritating since I always debug with "Break on exceptions" flag turned on. Here's the stack trace:
System.Windows.dll!MS.Internal.XcpImports.MethodEx(System.IntPtr ptr, string name, MS.Internal.CValue[] cvData) + 0x176 bytes
System.Windows.dll!MS.Internal.XcpImports.MethodPack(System.IntPtr objectPtr, string methodName, object[] rawData) + 0x682 bytes    
System.Windows.dll!MS.Internal.XcpImports.UIElement_TransformToVisual(System.Windows.UIElement element, System.Windows.UIElement visual) + 0x54 bytes   
System.Windows.dll!System.Windows.UIElement.TransformToVisual(System.Windows.UIElement visual) + 0x5 bytes  
System.Windows.Controls.Toolkit!System.Windows.Controls.Primitives.VisualTreeExtensions.GetBoundsRelativeTo(System.Windows.FrameworkElement element, System.Windows.UIElement otherElement) + 0xd7 bytes    
SL4PopupMenu!SL4PopupMenu.PopupMenuUtils.HitTest(System.Windows.Input.MouseEventArgs e, bool isPopupChild, System.Windows.FrameworkElement element) + 0x86 bytes    
SL4PopupMenu!SL4PopupMenu.PopupMenuUtils.HitTestAny(System.Windows.Input.MouseEventArgs e, bool isPopupChild, System.Windows.FrameworkElement[] elements) + 0x7b bytes  
SL4PopupMenu!SL4PopupMenu.PopupMenuBase.AddOverlayCanvasEventHandlers.AnonymousMethod__1c(object sender, System.Windows.Input.MouseEventArgs e) + 0x53e bytes   
System.Windows.dll!MS.Internal.CoreInvokeHandler.InvokeEventHandler(uint typeIndex, System.Delegate handlerDelegate, object sender, object args) + 0x868 bytes  
System.Windows.dll!MS.Internal.JoltHelper.FireEvent(System.IntPtr unmanagedObj, System.IntPtr unmanagedObjArgs, int argsTypeIndex, int actualArgsTypeIndex, string eventName, uint flags) + 0x3b9 bytes 
[Appdomain Transition]  


ZiadJ wrote Aug 25, 2011 at 1:09 AM

Can you please send me a sample code so I can debug it on my machine?

skalkin wrote Aug 30, 2011 at 7:44 PM

That's interesting, I can't reproduce the problem on the sample project, but it fails on my real project. Essentially, I do pretty much this (adapted to be used in a vanilla sl app):
     LayoutRoot.MouseRightButtonDown += (sender, args) =>
           var menu = new PopupMenu();
           var exitMenuItem = menu.AddItem("Exit", delegate { });
           var foo = menu.AddItem("Foo", delegate { });

           var viewMenu = new PopupMenu();
           foreach (var cmd in new[] {"Open", "Reset"})
              viewMenu.AddItem(cmd, delegate { });

           menu.AddSubMenu(viewMenu, "View", null, null, null, false, null);

           menu.Showing += (_, __) => exitMenuItem.IsEnabled = exitMenuItem.IsVisible = true;

           menu.Open(args.GetPosition(null), false, false);

           args.Handled = true;
and I always get this exception when you hover mouse over "View" and then go up to "Reset".

skalkin wrote Sep 1, 2011 at 5:43 AM

Well, as I said so far I failed to reproduce it on a sample app. The real app (on which it is 100% reproducible) has lots of controls underneath the popup menu, so that might make a difference. I'll keep trying.

skalkin wrote Sep 1, 2011 at 5:45 AM

Well, as I said I failed to reproduce it with a simple app; the real app (where it is 100% reproducible) has lots of controls under the popup, so that might make the difference. The real app won't be of any use to you. I'll keep trying to make a good repro.