We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Unknown Exception occured during Report Generation

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 ( 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)
        // Check if reportDocument is null
        if (reportDocument != null)
            // Check Elementdoc is Null
            if (elementDoc != null)
                // Close and Dispose ElementDoc
            // Create New ElementDoc
            elementDoc = new MemoryStream();
            // Update the page count before saving
            switch (docFormat.ToLower())
                case "pdf":
                    reportDocument.SaveToPdf(0, reportDocument.PageCount, elementDoc, null);
                case "word 2003":
                case "word 2000":
                    reportDocument.Save(elementDoc, SaveFormat.Doc);
                    SaveFormat saveFormat = (SaveFormat) Enum.Parse(typeof(SaveFormat), docFormat, true);
                    reportDocument.Save(elementDoc, saveFormat);
    catch (Exception generalException)
        throw new AppException(ExceptionConstants.ERROR_GET_PRINTED_ELEMENT, ExceptionSeverityType.Error, generalException);
        documentBuilder = null;
        reportDocument = null;
        docFormat = null;

Please let us know if any other information required on this.
Thanks in Advance.


Thanks for your inquiry. Please tell us about your production environment (e.g. Which hosting server you are using? What version of which OS is being used?). Moreover, could you please attach your input document(s) here for testing. I will investigate the problem on my side and provide you more information.

Best Regards,

Hi ,
This is a Application server who is responsible to Generate Reports. There is a Window Service which is picking up the Messages from queues and generate reports.
The OS of the server is - Microsoft Windows Server 2003 R2, Standard edition, SP2.
Also Please let me know what type of input documents you requires i am not clear?

Thank you for additional information. Awais meant the document you are using as a template for generating reports. Also, it would be great if you provide a simple code that will allow us to reproduce the problem.
Best regards,

Thanks for your quick response. please find the attached template generally used in reports.
I am sorry we cannot send you sample code as per aggregement with the client.
Please let us know if any other information required.

Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side. I used the latest version of Aspose.Words for testing. You can download the latest version from here:
With the latest version I can open/save your document in all formats supported by Aspose.Words. So please try using the latest version of Aspose.Words.
Best regards,