我使用VS 2012,asp.net 4.5.1和 ReportViewer (Microsoft.Reporting.WebForms
和本地 RDLC文件)。
现在,在生产环境中,我得到错误 OutOfMemoryException 和 LocalProcessingException ,输出格式为 Excel xlsx和PDF文件
我使用localReport.Render
获取字节并使用Response.BinaryWrite
Exception of type 'System.OutOfMemoryException' was thrown.
Void Unload(System.AppDomain) 在System.AppDomain.Unload(AppDomain域) 在Microsoft.Reporting.ReportCompiler.CompileReport(CatalogItemContext context,Byte [] reportDefinition,Boolean generateExpressionHostWithRefusedPermissions,ReportSnapshotBase& 快照) 在Microsoft.Reporting.StandalonePreviewStore.StoredReport.CompileReport() 在Microsoft.Reporting.StandalonePreviewStore.StoredReport.get_Snapshot() 在Microsoft.Reporting.StandalonePreviewStore.GetCompiledReport(CatalogItemContext context,Boolean rebuild,ReportSnapshotBase&快照) 在Microsoft.Reporting.LocalService.GetCompiledReport(CatalogItemContext itemContext,Boolean rebuild,ReportSnapshotBase&快照) 在Microsoft.Reporting.WebForms.LocalReport.CompileReport()
Microsoft.Reporting.WebForms.LocalProcessingException, Microsoft.ReportViewer.WebForms,Version = 9.0.0.0,Culture = neutral, 公钥= b03f5f7f11d50a3a
An error occurred during local report processing
我的代码:
var reporteDataSourceClients = new ReportDataSource("ClientsMyReport", lstClient);
localReport.DataSources.Add(reporteDataSourceClients);
MyReport.GenerateMyReport(OutputType.Excel, localReport, "MyReport Clients");
public static void GenerateMyReport(OutputType outputType, LocalReport localReport, string titleMyReport)
{
try
{
string reportType = outputType.ToString();
string mimeType;
string encoding;
string fileNameExtension;
Warning[] warnings;
string[] streams;
string deviceInfo = "<DeviceInfo><SimplePageHeaders>False</SimplePageHeaders></DeviceInfo>";
byte[] renderedBytes = localReport.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);
HttpContext.Current.Response.Clear();
switch (outputType)
{
case OutputType.Pdf:
HttpContext.Current.Response.ContentType = "application/pdf";
break;
case OutputType.Excel:
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
break;
}
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + titleMyReport + "." + fileNameExtension);
HttpContext.Current.Response.BinaryWrite(renderedBytes);
HttpContext.Current.Response.End();
//HttpContext.Current.Response.Flush();
//HttpContext.Current.Response.Close();
}
catch (LocalProcessingException ex)
{
throw ex;
}
catch (Exception ex)
{
throw ex;
}
}
任何sugesstions?