Does Document.Save() uses culture-sepecific information while saving a document?

While trying to save a document facing the below error?

System.Globalization.CultureNotFoundException: Only the invariant culture is supported in globalization-invariant mode. See https://aka.ms/GlobalizationInvariantMode for more information. (Parameter 'name')\nen-nz is an invalid culture identifier

But the document does not have any date, numbers or any culture-sepcific text. So whenver we save a document do we use some default culture-specific information to save?

Below is the code snippet

// Save the Document as HTML
using(MemoryStream stream = new MemoryStream()) {
    newDocument.Save(stream, SaveFormat.Html);
    stream.Position = 0;
    using(StreamReader reader = new StreamReader(stream)) {
        return reader.ReadToEnd();
    }
}

Facing the issue in newDocument.Save(stream, SaveFormat.Html);

@imsuhas Could you please attach your problematic input document here for testing? Also, I would recommend to set InvariantGlobalization option to false in your project:

<InvariantGlobalization>false</InvariantGlobalization>
1 Like