I'm trying to implement the IXmlSerialization for class SerializableDictionary. When starts the serialization of class to xml, I'm catching the System.NotSupportedException: 'Can't flush final block twice'. The problem occurs when second serializer trying to call Serialize method on same XmlWriter.
using (var archive = new ZipArchive(stream, ZipArchiveMode.Create, false, null))
{
foreach (var item in array)
{
using (var entry = archive.CreateEntry($"{item.Name}.reg-ext"))
{
XmlInOut<RegulationItem>.SaveToStream(entry.Open(), item);
}
}
}
Could it be bug with the ArchiveEntry Stream?
I've placed a solution into a github repo. Also I tried to replace the stream of entry with the MemoryStream, and it helps. But I would to do it directly, if it's possible.