Pending Review
Last Updated: 15 Jul 2025 10:44 by Reilly
Reilly
Created on: 15 Jul 2025 10:44
Category: UI for WPF
Type: Bug Report
0
RichTextBox null reference exception loading docx

Windows 11

VS 2022

UI for WPF (2024 Q4)

.NET 8

Binaries.NoXaml\WPF80\Telerik.Windows.Controls.RichTextBox.dll (2024.4.1213.80)

I can create a docx file with Word that results in a null reference exception at

NameValueType
StackTrace" at Telerik.Windows.Documents.Layout.ParagraphLayoutBox.ArrangeOverride(SizeF finalSize) in Telerik.Windows.Documents.Layout\\ParagraphLayoutBox.cs:line 1174"string

Since this exception is in a threadpool that is doing layout, the exception cannot be caught and is not recoverable.

It is easy to reproduce (see attached file). First create a Word doc with a large image that is anchored. Then add a bookmark. Removing either the bookmark or the "square" text wrapping removes the exception.

The code to load the document and display it is very simple:


   private string? LoadDocx(
      string path)
   {
      string? msg = null;
      try
      {
         using var instream = File.OpenRead(path);

         var openXmlRadDocProvider =
            new Telerik.Windows.Documents.FormatProviders.OpenXml.Docx.DocxFormatProvider();

         var raddoc = openXmlRadDocProvider.Import(instream);
         RadRtb.Document = raddoc;
      }
      catch (Exception ex)
      {
         msg = ex.Message;
      }

      return msg;
   }

"RadRtb" is a "RadRichTextBox". This method returns fine. The exception happens later in a non-UI threadpool thread.

 

While I don't expect the component to correctly render EVERY Word document, I do expect it to not exception on a valid document. There must be a better way to handle this.

 

 

0 comments