The namespace declaration attribute has an incorrect 'namespaceURI': 'http://www.w3.org/2000/xmlns/'

Hi.
Next code throws error “The namespace declaration attribute has an incorrect ‘namespaceURI’: ‘A Namespace Name for xmlns Attributes’”:

Document document = new Document(“some file name”);
var taggedContent = document.TaggedContent;

StackTrace:
at System.Xml.XmlDocument.AddAttrXmlName(String prefix, String localName, String namespaceURI, IXmlSchemaInfo schemaInfo) in //src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlDocument.cs:line 246
at System.Xml.XmlDocument.CreateAttribute(String prefix, String localName, String namespaceURI) in /
/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlDocument.cs:line 1077
at System.Xml.XmlDocument.CreateAttribute(String name) in //src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlDocument.cs:line 621
at System.Xml.XmlElement.SetAttribute(String name, String value) in /
/src/libraries/System.Private.Xml/src/System/Xml/Dom/XmlElement.cs:line 292
at #=zjQRU3Ao6xrQglQDRuDAyxDoJwXDnliF5fgby7_8=.#=zK0TKl6M=()
at #=zRur_uMF2pkzVB0ObnCEGKmOTmZX_fGcNN3L5eHU=.#=zO7BbkWdjmvny(XmlWriter #=z2SoVpeo=, #=znW6c6Kz1bkIt6JQavitBbpbULd53Eoll4VBbe7g= #=z4CBTcAA=)
at #=zRur_uMF2pkzVB0ObnCEGKmOTmZX_fGcNN3L5eHU=.#=zO7BbkWdjmvny(Stream #=zpCqxRiM=, Int32 #=zS9olONc=)
at #=zvtO6Ng$WpwYB54ImeHA3xachkgcINUx$g3YrQuY=.#=zAXS20pc=(#=zRur_uMF2pkzVB0ObnCEGKmOTmZX_fGcNN3L5eHU= #=znMMS7AE=, Boolean #=zzXFX2oqk_4XT)
at #=zvtO6Ng$WpwYB54ImeHA3xachkgcINUx$g3YrQuY=.#=z3eVHLp4ztRSz(#=zRur_uMF2pkzVB0ObnCEGKmOTmZX_fGcNN3L5eHU= #=zK1Y9$H4=)
at #=zuTuMyEuDuO0yqfG15EVOd7ocgYLG.#=z41mhV3jKGcJ1()
at #=zuTuMyEuDuO0yqfG15EVOd7ocgYLG…ctor(Document #=z_UAyEcE=)
at #=zHfMpHx8S3XPVBqRdjpgWwigKIRkX…ctor(Document #=z_UAyEcE=)
at Aspose.Pdf.Document.get_TaggedContent()

The error has occurred once on different files. Unfortunately it cannot be reproduced. Can you suggest any possible reasons?

Tech stack: Aspose.PDF 22.11.0, .Net 5
OS: CentOS 8

Hi @asposeuuups
I correctly understood that the error occurred once and is no longer reproduced. Even if you try to repeat everything the same way?

Yes, I have not found a way to reproduce it.

@asposeuuups
Can you provide a file with which this exactly happened?

@sergei.shibanov
I have added one of the files with which there was a problem. However, the problem does not seem to be related to a specific file, but rather to a situation when many files are being processed at the same time.
Dogovir _Test vid 17.03.2022.docx (16.9 KB)

@asposeuuups
Doesn’t it turn out that one document is processed in several threads/processes? This feature is not supported by the library.

@sergei.shibanov
We’re actually creating a document from a MemoryStream, so it’s a new document every time.
I added a very simplified version of the code first, it actually looks something like this:

private byte[] TestMethod(byte[] pdfDocIn)
{
    using (var pdfDocStream = new MemoryStream())
    {
        pdfDocStream.Write(pdfDocIn, 0, pdfDocIn.Length);
        pdfDocStream.Seek(0, SeekOrigin.Begin);
        using (var pdfDoc = new Aspose.Pdf.Document(pdfDocStream))
        {
            var taggedContent = document.TaggedContent;
			//some another code
            pdfDoc.Save(pdfDocStream);
            pdfDoc.FreeMemory();
        }
        return pdfDocStream.ToArray();
    }
}

@asposeuuups
Thanks for the code snippet. We will try to reproduce the problem

@asposeuuups
Do I understand correctly that the call to the method TestMethod is carried out as follows?

var result = TestMethod(File.ReadAllBytes(myDir + "Dogovir _Test vid 17.03.2022.docx"));

@sergei.shibanov
Sorry, the file is converted to pdf before calling TestMethod.
Dogovir _Test vid 17.03.2022.pdf (53.6 KB)

@asposeuuups
Please see if I am trying to reproduce the error correctly, based on the given code?
(this fragment works without errors on my environment)

static private byte[] TestMethod()
{
    var document = new Document(myDir + "Dogovir _Test vid 17.03.2022.pdf");

    var pdfDocIn = File.ReadAllBytes(myDir + "Dogovir _Test vid 17.03.2022.pdf");

    using (var pdfDocStream = new MemoryStream())
    {
        pdfDocStream.Write(pdfDocIn, 0, pdfDocIn.Length);
        pdfDocStream.Seek(0, SeekOrigin.Begin);
        using (var pdfDoc = new Aspose.Pdf.Document(pdfDocStream))
        {
            var taggedContent = document.TaggedContent;
            //some another code
            pdfDoc.Save(pdfDocStream);
            pdfDoc.FreeMemory();
        }
        return pdfDocStream.ToArray();
    }
}

Almost.

    static private byte[] TestMethod(byte[] pdfDocIn)
    {
        using (var pdfDocStream = new MemoryStream())
        {
            pdfDocStream.Write(pdfDocIn, 0, pdfDocIn.Length);
            pdfDocStream.Seek(0, SeekOrigin.Begin);
            using (var pdfDoc = new Aspose.Pdf.Document(pdfDocStream))
            {
                var taggedContent = pdfDoc.TaggedContent;
                //some another code
                pdfDoc.Save(pdfDocStream);
                pdfDoc.FreeMemory();
            }
            return pdfDocStream.ToArray();
        }
    }

and

var result = TestMethod(File.ReadAllBytes(myDir + "Dogovir _Test vid 17.03.2022.pdf"));

But as I said “the problem does not seem to be related to a specific file, but rather to a situation when many different files are being processed at the same time.”

@asposeuuups
The development team says that in one of the latest releases there were changes regarding the simultaneous work with many documents. Try the latest version of the library - 23.4

Hi, @sergei.shibanov , we are using Aspose.PDF 24.1.0 on .Net 6 and running into this error. Has there been changes since this version that might re-introduce a bug on ‘simultaneous work with many documents’? Thanks!

@dchug

Looks like you have already created a separate topic for this issue where we have already responded to you. Please follow up there.

Hi @asad.ali , I don’t think this is related to the NullReferenceException that I posted. May I get some support on figuring out if there been changes since Aspose.pdf for .NET version 24.1.0 that might re-introduce a bug on ‘simultaneous work with many documents’? Thanks!

Also what specifically was the change in the release notes for version 23.4 that addressed ‘simultaneous work with many documents’?

@dchug

We are checking this and will get back to you shortly.

@dchug

Around that time, there were changes associated with simultaneous work on several DIFFERENT documents. I can’t say about the details now, but they were there. It just obviously didn’t help with your problem.

The development team did nothing specifically in this area. Have you experienced noticeable deterioration since version 24.01? Perhaps you could provide code with test data that would allow you to reproduce the error?