The document appears to be corrupted and cannot be loaded. Cannot insert a node of this type at this location

We have problems with the news versions of aspose.words, a docx file load from memory stream is taken as corrupted files since 20.7.0 version, the same docx works fine in 20.6.0 version.
The error is loading the file and we cannot to see any thing that this exception:

    *"Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.\r\n ---> System.ArgumentException: Cannot insert a node of this type at this location.\r\n   at Aspose.Words.CompositeNode.\u0002 (Node \u0002, Node \u0003, Boolean \u0005)\r\n   at Aspose.Words.CompositeNode.InsertAfter(Node newChild, Node refChild)\r\n   at \u0005   .\u000e (Node \u0002, Node \u0003)\r\n   at \u0005   .\u0006 (Node \u0002, Node \u0003)\r\n   at \u0005   .\u000f (Node \u0002)\r\n   at \u0005   .\u0005     \u000e()\r\n   at \u0005   .\u0003()\r\n   at \u0005   .\u0006 ()\r\n   at \u0005   .\u000e (\u0003    \u0002, Node \u0003, \u000e    \u0005, \u0002    \b, \b    \u0006)\r\n   at \u0005   .\b (Document \u0002, CompositeNode \u0003, ImportFormatMode \u0005)\r\n   at \u0005   .\u0002 ()\r\n   at \u0005   .\u000e ()\r\n   at \u000e   .\u0003 ()\r\n   at \u000e   .\u000f()\r\n   at \u0003   .\u000e     \u0002()\r\n   at Aspose.Words.Document.\u0005 (Stream \u0002, LoadOptions \u0003)\r\n   --- End of*
*     inner exception stack trace ---\r\n   at Aspose.Words.Document.\u0005 (Stream \u0002, LoadOptions \u0003)\r\n   at Aspose.Words.Document.\u0003 (Stream \u0002, LoadOptions \u0003)\r\n   at Aspose.Words.Document..ctor(String fileName, LoadOptions loadOptions)\r\n   at Aspose.Words.Document..ctor(String fileName)\r\n   at QP.Arq.PDF.Infrastructure.PDF.AsposeWord.Convert(Byte[] archivo) in C:\\Projects\\PDF\\src\\QP.Arq.PDF.Infrastructure\\PDF\\AsposeWord.cs:line 39\r\n   at QP.Arq.PDF.Infrastructure.PDF.AsposeConvertPdf.Convert(Byte[] doc, PdfOptions pdfOptions, DocEntryType docEntryType) in C:\\Projects\\PDF\\src\\QP.Arq.PDF.Infrastructure\\PDF\\AsposeConvertPdf.cs:line 54\r\n   at QP.Arq.PDF.Application.PDF.Queries.ConvertToPdfQueryHandler.Handle(ConvertToPdfQuery request, CancellationToken cancellationToken) in C:\\Projects\\PDF\\src\\QP.Arq.PDF.Application\\PDF\\Queries\\ConvertToPdf\\ConvertToPdfQuery.cs:line 40\r\n   at MediatR.Wrappers.RequestHandlerWrapperImpl`2.<>c__Dis*
*    playClass1_0.<Handle>g__Handler|0()\r\n   at QP.Arq.PDF.Application.Common.Behaviours.UnhandledExceptionBehaviour`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next) in C:\\Projects\\PDF\\src\\QP.Arq.PDF.Application\\Common\\Behaviours\\UnhandledExceptionBehaviour.cs:line 29"*

This is our code:

public byte[] Convert(byte[] archivo)
{
    byte[] archivoPdf;

    var doc = new Document(new MemoryStream(archivo));  //Exception line
    doc.UpdateFields();

    PdfSaveOptions pdfoptions = new() { SaveFormat = SaveFormat.Pdf };

    if (doc.HasMacros)
    {
        doc.RemoveMacros();
    }

    using (MemoryStream ms2 = new())
    {
        doc.Save(ms2, pdfoptions);
        archivoPdf = ms2.ToArray();
    }

    return archivoPdf;
}

The docx is generated with Open XML libraries.

We have recently licensed de last version of Aspose Total.

@jcgm2 Could you please attach your problematic document here for testing? We will check the issue and provide you more information.

The document has confidential information. Do we have a guarantee that if we upload it, only aspose staff will see it and guarantee confidentiality?

@jcgm2 It is safe to upload your documents to the forum. Your attachments can only be downloaded by you and Aspose employees.

File_20220816_115311 original.docx (299.7 KB)
This is the example.

Thanks

@jcgm2 I was managed to reproduce your issue on my side. I have logged it as WORDSNET-24236 in our defect tracking system. We will keep you informed and let you know once it is resolved.

The issues you have found earlier (filed as WORDSNET-24236) have been fixed in this Aspose.Words for .NET 22.9 update also available on NuGet.