This bug is inside AvalonDock within the Xceed Extended WPF Toolkit version 2.2.1:
Closing a LayoutAnchorable that is docked inside a LayoutDocumentPane causes an infinite loop, resulting in a StackOverflowException.
Looking at the call stack, it looks like LayoutAnchorable.Close() results in an event triggered in the docking manager, which in turn calls LayoutAnchorable.Close() forever looping:
```
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutElement.Root.get()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
//// ... and so on
```
I have attached a small sample app which demonstrates this bug. In it, we have a WPF app with a LayoutDocumentPane containing a LayoutDocument ("Document") and a LayoutAnchorable ("Close Me"). Upon closing the "Document", the app behaves as expected. Upon closing the "Close Me" tab, the StackoverFlowException bug occurs.
Comments: ** Comment from web user: Ricje **
Closing a LayoutAnchorable that is docked inside a LayoutDocumentPane causes an infinite loop, resulting in a StackOverflowException.
Looking at the call stack, it looks like LayoutAnchorable.Close() results in an event triggered in the docking manager, which in turn calls LayoutAnchorable.Close() forever looping:
```
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutElement.Root.get()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.DockingManager._ExecuteCloseCommand(Xceed.Wpf.AvalonDock.LayoutAnchorable anchorable)
Xceed.Wpf.AvalonDock.dll!Xceed.Wpf.AvalonDock.Layout.LayoutAnchorable.Close()
//// ... and so on
```
I have attached a small sample app which demonstrates this bug. In it, we have a WPF app with a LayoutDocumentPane containing a LayoutDocument ("Document") and a LayoutAnchorable ("Close Me"). Upon closing the "Document", the app behaves as expected. Upon closing the "Close Me" tab, the StackoverFlowException bug occurs.
Comments: ** Comment from web user: Ricje **
Seem like I get the exact same exception as you... And it can simply be reproduced using the LiveExplorer shipped with the source code drop of the Extended WPF Toolkit 2.2.1
See https://wpftoolkit.codeplex.com/discussions/559941 for my post asking for a workaround to this issue.