Showing a document that contains a Table object without any TableRow inside leads to NullReferenceException.
Workaround: After importing the document, remove the tables that don't have content:
foreach (var table in document.EnumerateChildrenOfType<Table>())
{
if (table.Rows.Count < 1)
{
table.Parent.Children.Remove(table);
}
}
To reproduce:
The issue is a regression introduced in R3 2021 SP1.
The parent of an already removed span cannot be found and a NullReferenceException is thrown while performing Undo. Also, multiple asserts are failing in Debug mode. The stack trace is: UnhandledException: Object reference not set to an instance of an object. UnhandledException: at Telerik.Windows.Documents.Layout.LayoutElement.SetParent(LayoutElement newParent) at Telerik.Windows.Documents.Layout.LayoutBox.EnsureParent() at Telerik.Windows.Documents.Layout.LayoutBox.get_Parent() at Telerik.Windows.Documents.Layout.LayoutBox.get_ValidParent() at Telerik.Windows.Documents.WordPositionHandler.GetParentHandler() at Telerik.Windows.Documents.DocumentPosition.GetCurrentSectionBox() at Telerik.Windows.Documents.UI.DocumentPrintLayoutPresenter.GetCurrentPage() at Telerik.Windows.Documents.UI.DocumentPrintLayoutPresenter.MeasureOverride(Size availableSize) at System.Windows.FrameworkElement.MeasureCore(Size availableSize)