繁体   English   中英

索引超出范围。 在处理本地报告期间,必须为非负数并且小于集合的大小

[英]Index was out of range. Must be non-negative and less than the size of the collection during processing local report

我得到以下异常

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

调用此方法时:

private void AddReportToResponse(LocalReport Report)
{
    string mimeType;
    string encoding;
    string extension;
    string[] streams = new string[100];
    Warning[] warnings = new Warning[100];
    byte[] pdfStream = Report.Render("PDF", "", out mimeType, out encoding, out extension, out streams, out warnings);//The error here
    Response.Clear();
    Response.ContentType = mimeType;
    Response.AddHeader("content-disposition", "attachment; filename=Application." + extension);
    Response.BinaryWrite(pdfStream);
    Response.End();
}

堆栈跟踪:

[ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
   System.Collections.ArrayList.get_Item(Int32 index) +7487176
   Microsoft.ReportingServices.Rendering.ImageRenderer.MatrixCellCollection.get_Item(Int32 index) +36
   Microsoft.ReportingServices.Rendering.ImageRenderer.MatrixCellGrid.get_Item(Int32 column, Int32 row) +109
   Microsoft.ReportingServices.Rendering.ImageRenderer.Matrix.ResizeCellsHorizontally(ReAdjustments& itemReAdjustment, Double& rowHeadersWidth, Int32& firstRowOnPage, Int32& firstRowHeadersCol, Int32& lastRowHeadersCol, Double& newChildrenMaximumDistance) +293
   Microsoft.ReportingServices.Rendering.ImageRenderer.Matrix.CalculateItemMeasurement(Orientation orientation, Double childrenMaximumDistance, ReAdjustments itemReAdjustment, ItemContext savedContext) +1611
   Microsoft.ReportingServices.Rendering.ImageRenderer.RenderingItemContainer.CalculatePage(Orientation orientation, Boolean repeatableParent, Boolean canDelete, Double& minimumCoordinate, Double& distance) +3566
   Microsoft.ReportingServices.Rendering.ImageRenderer.RenderingItemContainer.CalculatePage(Orientation orientation, Boolean repeatableParent, Boolean canDelete, Double& minimumCoordinate, Double& distance) +2717
   Microsoft.ReportingServices.Rendering.ImageRenderer.RenderingItemContainer.CalculatePage(Orientation orientation, Boolean repeatableParent, Boolean canDelete, Double& minimumCoordinate, Double& distance) +2717
   Microsoft.ReportingServices.Rendering.ImageRenderer.RenderingItemContainer.CalculatePage(Orientation orientation, Boolean repeatableParent, Boolean canDelete, Double& minimumCoordinate, Double& distance) +2717
   Microsoft.ReportingServices.Rendering.ImageRenderer.RenderingItemContainer.CalculatePage(Orientation orientation, Boolean repeatableParent, Boolean canDelete, Double& minimumCoordinate, Double& distance) +2717
   Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRendererBase.ProcessPages(CompositionBase theComposition, Report theReport, Boolean needTotalPages, Int32 startPage, Int32 endPage, Boolean render) +325
   Microsoft.ReportingServices.Rendering.ImageRenderer.PdfReport.RenderReport(Report report, NameValueCollection deviceInfo, EvaluateHeaderFooterExpressions evaluateHeaderFooterExpressions, CreateAndRegisterStream createAndRegisterStreamCallback, Int32 streamPageNumber) +324
   Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRendererBase.Render(Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, EvaluateHeaderFooterExpressions evaluateHeaderFooterExpressions, CreateAndRegisterStream createAndRegisterStream) +81

[ReportRenderingException: An error occurred during rendering of the report.]
   Microsoft.ReportingServices.Rendering.ImageRenderer.ImageRendererBase.Render(Report report, NameValueCollection reportServerParameters, NameValueCollection deviceInfo, NameValueCollection clientCapabilities, EvaluateHeaderFooterExpressions evaluateHeaderFooterExpressions, CreateAndRegisterStream createAndRegisterStream) +142
   Microsoft.ReportingServices.ReportProcessing.ReportProcessing.RenderReport(IRenderingExtension renderer, DateTime executionTimeStamp, GetReportChunk getCompiledDefinitionCallback, ProcessingContext pc, RenderingContext rc, CreateReportChunk cacheDataCallback, Boolean& dataCached) +1775

经过大量的搜索和调试,我发现了问题的原因:

我在报表中使用了matrix ,而且渲染可能不正确,因此我只是尝试将此矩阵的数据源设置为空数据表,并且工作正常。 所以我知道问题出在哪里,经过一些(调整)矩阵的高度和宽度后,所有事情都可以了:

在此处输入图片说明

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM