2014-12-08 58 views
0

过程中出现了以下情况例外指数超出范围。必须小于集合的大小非负少处理本地报告

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 

回答

0

经过大量的搜索和调试,我找到了问题的原因。

我在我的report.and中使用了matrix,可能渲染不正确,所以我只是试图将这个矩阵的数据源设置为空数据表,并且它工作正常。所以我知道问题出在哪里, (调整)矩阵的高度和宽度,每件事情都可以。


enter image description here

相关问题