??recently got a dump, there is an application crash, by looking at dump, the exception information is as follows:
0:012>
!pe Exception object:0000000005187278Exception type:System.NullReferenceExceptionmessage:object Reference not set to a instance of an Object.innerexception: <none>StackTrace (generated):SP IP Function000000002144db50 000007feedf84989 presentationframework_ni! System.Windows.Controls.TreeViewItem.ExpandRecursive (System.Windows.Controls.TreeViewItem) +0x119000000002144DC10 000007feedf84b46 presentationframework_ni! System.Windows.Controls.TreeViewItem.ExpandRecursive (System.Windows.Controls.TreeViewItem) +0X2D6000000002144dcd0 000007feede574b8 presentationframework_ni! System.Windows.Controls.TreeView.ExpandSubtree (System.Windows.Controls.TreeViewItem) +0x18 000000002144dd00 000007feede572f5 presentationframework_ni! S
ystem. Windows.Controls.TreeView.OnKeyDown (System.Windows.Input.KeyEventArgs) +0x135000000002144DD40 000007fef116b1e3 presentationcore_ni! System.Windows.RoutedEventArgs.InvokeHandler (System.Delegate, System.Object) +0x53000000002144dda0 000007fef116a991 presentationcore_ni! System.Windows.EventRoute.InvokeHandlersImpl (System.Object, System.Windows.RoutedEventArgs, Boolean) +0x271000000002144dfe0 000007fef115408e presentationcore_ni! System.Windows.UIElement.RaiseEventImpl (System.Windows.DependencyObject, System.Windows.RoutedEventArgs) +0x14e 000000002144E070 000007fef114ff66 presentationcore_ni! System.Windows.UIElement.RaiseTrustedEvent (System.Windows.RoutedEventArgs) +0x96000000002144e0d0 000007fef117c921 presentationcore_ni! System.Windows.Input.InputManager.ProcessStagingArea () +0x471000000002144E160 000007fef117c42b presentationcore_ni! System.Windows.Input.InputManager.ProcessInput (System.Windows.Input.InputEventArgs) +0xab000000002144e1b0 000007FEF117C1BC presentationcore_ni! System.Windows.Interop.HwndKeyboardInputProvider.ReportInput (IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawKeyboardActions, Int32, Boolean, Boolean, Int32) +0X1BC
!pe is printexception, which can be seen from the exception stack information when a key was pressed on the TreeView to cause the TreeView to expand TreeViewItem, and then the loop throws a null pointer exception.
The next step is to see which of the KeyDown events were passed, and someone who looked at Google said that the address of the function parameter could be seen through!clrstack-p, but that the WinDbg command did not work because it was the release version. only in a stupid way, through!DSO to see all the stack variables of the whole thread at that time, as follows:0:012>
~12e!dso
OS Thread ID:0XBA4 (12)
Rsp/reg Object Name
00000000214479b0 0000000005187278 syste.nullreferenceexception000000002144dcb0
00000000051840c8 System.Windows.Input.KeyEventArgs
000000002144dcc0 0000000002d728f8 System.Windows.Controls.TreeView
000000002144dcd0 00000000041c1188 System.Windows.Controls.TreeViewItem
The above 12 is the exception of the CLR thread number, you can view all the field stack through ~*KB, you can know the specific thread number from the above command part of the information can be seen at the time KeyEventArgs address.
Next, use the!do command to view specific information012>
!do 00000000051840c8 Name:System.Windows.Input.KeyEventArgsmethodtable:000007fef1283900eeclass:000007fef0ee4de0size:80 (0x50) bytesfile:c:\windows\microsoft.net\assembly\gac_64\presentationcore\v4.0_4.0.0.0__31bf3856ad364e35\ PresentationCore.dllFields :MT Field Offset Type VT Attr Value Name000007fef5070c78 40001c7 System.EventArgs 0 shared static Empty>> domain:value 00000000008083f0:0000000002bd96d0 <<000007fef1279088 40012ff 8 ... ndows. RoutedEvent 0 Instance 0000000002ba43d0 _routedevent000007fef5055ac8 4001300 System.Object 0 instance 0000000002d728f8 _source000007fef5055ac8 4001301 System.Object 0 instance 00000000041c1188 _originalsource000007fef43990a8 4001302 ... lized. BitVector32 1 Instance 00000000051840e8 _flags000007fef128b320 40016ce 28 ... Input.inputdevice 0 Instance 0000000002bc2f00 _inputdevice000007fef505c858 40016CF 1460 System.Int32 1 static 396682259 _timestamp000007fef3161bf0 40018ba System.Int32 1 instance _realkey000007fef3161bf0 40018BB 3c System.Int32 1 Instance
_key000007fef1283da8 40018BC resentationsource 0 instance 0000000003f8d7a0 _inputsource000007fef505d688 40018bd System.Boolean 1 Instance 0 _isrepeat000007fef505c858 40018be System.Int32 1 instance _scancode000007fef505d688 40018bf System.Boolean 1 Instance 0 _isextendedkey
You can see from above that the key key value is 84, by looking at the enum type key source code, found that 84 is *namespace System.Windows.Input{[ValueSerializer (typeof (Keyvalueserializer))][TypeConverter (typeof (Keyconverter))] Public enum Key {
NumPad9 = The
Multiply = A,Add =.Separator =,Subtract = TheDecimal =.Divide = The
By looking at the code of the TreeView, you can see that multiply's shortcut keys are Expandsubtree
Case key.multiply: if (Expandsubtree (_selectedcontainer)) {e.handled = true; } Break;
Conclusion: * is the default system shortcut for the TreeView control, which is used to expand TreeViewItem, which causes the exception to be thrown when recursively expanding a subkey when there is a problem with the style of the TreeView.
Workaround: Modify the style or block shortcut keys.
The WPF TreeView throws an exception when executing expandsubtree system.nullreferenceexception