Hi Aspose Team,
We are getting unknown exception during report generation, the exception details is shown below.
AppInnerException : System.ArgumentOutOfRangeException: Non-negative number required.
Parameter name: length
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
at ؗ.ؖ.ج(Int32 ֲ)
at ؗ.ؖ.ح(Int32 ԟ)
at ό.☿.WriteCore()
at ό.◕.( ◚)
at ό.☿.(ഋ Ꭳ, ♑ ♃)
at ╽.╼.▞()
at ╽.╼.VisitRowEnd(Row row)
at ╽.╼.▙(Section ⍰)
at ╽.╼.▗()
at ╽.╼.▕(╨ ╧)
at Aspose.Words.Document.Ԕ(Stream ԍ, String ԋ, SaveFormat ԕ)
at Aspose.Words.Document.Save(Stream stream, SaveFormat saveFormat)
at SHL.ReportEngine.ReportGenerator.BaseElement.BaseElement.GetPrintedElement(String docFormat, MemoryStream & elementDoc)
TaskId : 0
EventId : 0
ErrorDescription :
Data : System.Collections.ListDictionaryInternal
TargetSite: Void GetPrintedElement(System.String, System.IO.MemoryStream ByRef)
Stack Trace : at SHL.ReportEngine.ReportGenerator.BaseElement.BaseElement.GetPrintedElement(String docFormat, MemoryStream& elementDoc)
at SHL.ReportEngine.ReportGenerator.ReportElement.ReportElement.PrintElement(ReportElementBO reportElementBO, MemoryStream& printedElement, LayoutBO reportLayoutBO, Boolean isLastElement, Boolean isOrientationChanged, Boolean& isLayoutApplied, String previousElementClassName, Boolean isPreview, Boolean isFirstElement, Boolean& isTablePresent, Int32 localeId, Int32 reportDefinitionId, Int32 languageP41Id)
We have faced this issue regularly on our production servers, reports continiously getting failed and raised this exception. And after restarting the service report generation gets normal, we are suspecting that instance of Aspose.Word got corrupted and reports generation fails. We are using Aspose.Word version (9.0.0.0). Can you please asists what went wrong there.
Please find the Code snippets where exception occured.
public virtual void GetPrintedElement(string docFormat, ref MemoryStream elementDoc)
{
try
{
// Check if reportDocument is null
if (reportDocument != null)
{
// Check Elementdoc is Null
if (elementDoc != null)
{
// Close and Dispose ElementDoc
elementDoc.Close();
elementDoc.Dispose();
}
// Create New ElementDoc
elementDoc = new MemoryStream();
// Update the page count before saving
reportDocument.UpdatePageLayout();
switch (docFormat.ToLower())
{
case "pdf":
reportDocument.SaveToPdf(0, reportDocument.PageCount, elementDoc, null);
break;
case "word 2003":
case "word 2000":
reportDocument.Save(elementDoc, SaveFormat.Doc);
break;
default:
SaveFormat saveFormat = (SaveFormat) Enum.Parse(typeof(SaveFormat), docFormat, true);
reportDocument.Save(elementDoc, saveFormat);
break;
}
}
}
catch (Exception generalException)
{
throw new AppException(ExceptionConstants.ERROR_GET_PRINTED_ELEMENT, ExceptionSeverityType.Error, generalException);
}
finally
{
documentBuilder = null;
reportDocument = null;
docFormat = null;
}
}
Please let us know if any other information required on this.
Thanks in Advance.
Regards,
Jitender