Declined
Last Updated: 17 Jul 2025 14:32 by ADMIN
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.

 

 

3 comments
ADMIN
Dimitar
Posted on: 17 Jul 2025 14:32

Hi Reilly,

I am glad that this works now. Do not hesitate to contact us if you have other questions.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Reilly
Posted on: 17 Jul 2025 13:00

Hello Dimitar,

Thanks for your response.

I apologize wholeheartedly. My debugger was set to break on the null ref exception and I never hit continue to see if it was handled!

You are correct. This bug is fixed in 2025.2.707 for me.

I'm glad I renewed my license!

Regards,

-Reilly.

 

ADMIN
Dimitar
Posted on: 16 Jul 2025 09:23

Hello Reilly,

These exceptions seem to be handled in the latest version. I have tested this with the latest version, and the document with the image is loaded on my side. Can you test as well to confirm? 

I am looking forward to your reply.

Regards,
Dimitar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.