System.IO.IOException: Stream was too long error on .NET Core 2.0 application
- Dominant language
- C#
- Stars
- 4.6k
- Forks
- 605
- PR merge metrics
- No merged PRs in 30d
Description
In .NET Core 2 console application ([ConsoleApp1.zip](https://github.com/OfficeDev/Open-XML-SDK/files/1309342/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](https://github.com/OfficeDev/Open-XML-SDK/files/1309348/ConsoleApp2.zip)) works perfectly with 10 MB workset size.
Contributor guide
Assessment
This issue has not been assessed yet.