arichika / RotativaCore

for ASP.NET Core on Azure Web Apps (by Windows). Support .NETStandard 2.0
https://www.nuget.org/packages/RotativaCore/
MIT License
14 stars 6 forks source link

Cannot access a closed Stream. Object name: 'MemoryStream'. #16

Open Ketanchavdadev opened 1 year ago

Ketanchavdadev commented 1 year ago

Hi, We are getting above error when we do export ViewAsPdf. Below is the code snippets.

return new ViewAsPdf { Model = objReportProperty, CustomSwitches = customSwitch, FileName = reportName, PageOrientation = !string.IsNullOrEmpty(objReportProperty.ReportOptions.PageOrientation) && objReportProperty.ReportOptions.PageOrientation.ToLower() == MitoviaCamp.Utils.ConstantValues.PAGEORIENTATION_LAND ? Orientation.Landscape : Orientation.Portrait, PageSize = !string.IsNullOrEmpty(objReportProperty.ReportOptions.PageSize) && objReportProperty.ReportOptions.PageSize.ToLower() == MitoviaCamp.Utils.ConstantValues.PAGESIZE_A4 ? Size.A4 : Size.Letter, PageMargins = new Margins(ConstantValues.PAGEMARGIN_TOP, ConstantValues.PAGEMARGIN_RIGHT, ConstantValues.PAGEMARGIN_BOTTOM, ConstantValues.PAGEMARGIN_LEFT) };

arichika commented 1 year ago

"The Stream was already Closed when you tried to operate on it" error, so you need to look at the call stack when the exception occurs to make a determination.