Aspose Words for .NET throws an exception "Unable to cast object of type 'Aspose.Words.Run' to type 'Aspose.Words.Markup.StructuredDocumentTag' when using Document.Compare

Hello,

We are getting System.InvalidCastException when trying to use Compare function.

Stack Trace:

2022-03-17 08:31:38 2022-03-17T07:31:38.389591503Z stdout F at Aspose.Words.Document.Compare(Document document, String author, DateTime dateTime) 2022-03-17 08:31:38 2022-03-17T07:31:38.389583502Z stdout F at Aspose.Words.Document.Compare(Document document, String author, DateTime dateTime, CompareOptions options) 2022-03-17 08:31:38 2022-03-17T07:31:38.389575602Z stdout F at .(Document , Document , CompareOptions ) 2022-03-17 08:31:38 2022-03-17T07:31:38.389568201Z stdout F at .() 2022-03-17 08:31:38 2022-03-17T07:31:38.389561201Z stdout F at . () 2022-03-17 08:31:38 2022-03-17T07:31:38.3895529Z stdout F at .() 2022-03-17 08:31:38 2022-03-17T07:31:38.3895438Z stdout F at . (Node , Node ) 2022-03-17 08:31:38 2022-03-17T07:31:38.389525198Z stdout F System.InvalidCastException: Unable to cast object of type ‘Aspose.Words.Run’ to type ‘Aspose.Words.Markup.StructuredDocumentTag’. 2022-03-17 08:31:38 2022-03-17T07:31:38.389463694Z stdout F 2022-03-17 07:31:38,388 [ERROR]

Files that you can use to reproduce the issue are attached.

We kindly ask for support ASAP, as the bug is very critical for our product. Thanks.

docs_compare_bug_files.zip (29.6 KB)

@dkorolev I cannot reproduce the problem on my side using the latest 22.3 version of Aspose.Words. Here is code I used for testing:

Aspose.Words.Document docOld = new Aspose.Words.Document(@"C:\Temp\old.docx");
Aspose.Words.Document docNew = new Aspose.Words.Document(@"C:\Temp\new.docx");
docOld.Compare(docNew, "TEST", DateTime.Now);
docOld.Save(@"C:\Temp\out.docx");
docOld.Save(@"C:\Temp\out.pdf");