System.OutOfMemoryException 在 reportviewer winform 中 - 本地报表处理期间发生错误

System.OutOfMemoryException in reportviewer winform - an error occurred during local report processing

我用的是带有 ReportViewer 控件的 winform。加载数据报告时,显示错误:

An Error Occured during local report processing.
An unexpected error occurred in Report Processing.
Exception of type System.OutOfMemoryException

System.OutOfMemoryException details

我在表单加载事件中使用了这段代码:

ReportViewr1.ProcessingMode = ProcessingMode.Local
Dim ReportDataSource2 As New Microsoft.Reporting.WinForms.ReportDataSource
ReportDataSource2.Name = RPSet.DataSetName
ReportDataSource2.Value = ds.Tables(0)
ReportViewr1.LocalReport.ReportPath = "C:\Reports\Report1.rdlc"
ReportViewr1.LocalReport.DataSources.Add(ReportDataSource2)
ReportViewr1.RefreshReport()

其中 ds 是我的数据集。 我的系统配置是:
Windows8.1 64 位(正版)
酷睿 i7 处理器
8 GB DDR3 内存(1600 FSB)
2 GB DDR5 显卡
500GB 固态硬盘

我发现我的程序内存消耗只有 300 到 400 MB。 那为什么会内存不足呢? Only 322 MB consumed by program while processing - details

你试过rdlc中Tablix或Rectangle的属性吗?它包含一个选项,如

keep contents together on a single page, if possible

可以取消勾选。它会尝试加载同一页面或单个页面中的页面内容。有时会消耗更多内存。