Skip to content

System.IO.IOException: Stream was too long error on .NET Core 2.0 application #244

@LarinLive

Description

@LarinLive

In .NET Core 2 console application (ConsoleApp1.zip) writing a large Excel file stops with the following error:
System.IO.IOException: Stream was too long.
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.IO.Compression.WrappedStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at System.Xml.XmlUtf8RawTextWriter.FlushBuffer()
at System.Xml.XmlUtf8RawTextWriter.WriteAttributeTextBlock(Char* pSrc, Char* pSrcEnd)
at System.Xml.XmlUtf8RawTextWriter.WriteString(String text)
at System.Xml.XmlWellFormedWriter.WriteString(String text)
at DocumentFormat.OpenXml.OpenXmlElement.WriteAttributesTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlElement.WriteTo(XmlWriter xmlWriter)
at DocumentFormat.OpenXml.OpenXmlPartWriter.WriteElement(OpenXmlElement elementObject)
at ConsoleApp1.Program.WriteRandomValuesSAX(String fileName, String sheetName) in C:\Users\anton\Documents\Visual Studio 2017\Projects\ConsoleApplication2\ConsoleApp1\Program.cs:line 80
at ConsoleApp1.Program.Main(String[] args) in C:\Users\anton\Documents\Visual Studio 2017\Projects\ConsoleApplication2\ConsoleApp1\Program.cs:line 105

The application workset grew up to 4 GiB. But there is a x64 application, so the process memory is not limited by 4 GiB.

Meanwhile in .NET FW4.7 the same application (ConsoleApp2.zip) works perfectly with 10 MB workset size.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions