OutOfMemoryException using RDLC, LocalReport, Microsoft.Reporting.WebForms in ASP.NET 4.5
In my production environment, on ONE IIS server, I have 2 applications
v1 App, vS 2008, .NET 3.5), https: //server/v1/Ventas.aspx Works using local report (RDLC)
v2 App (VS 2012, .NET 4.5.1) ( https: //server/v2/Ventas.aspx gets OutOfMemoryException using local report (RDLC)
Pool for ecah application:
v1 → APPPOOL "xxx2001Pool" (MgdVersion: v2.0, MgdMode: classic, state: started) Account: domain \ MyAppPool
v2 -> APPPOOL "xxx2015Pool" (MgdVersion: v4.0, MgdMode: Classic, state: Start). Account: ApplicationPoolIdentity. (I am trying to use NETWORK SERVICE too)
I don't know what the problem is: IIS config, pool, site, web.config, HttpContext.Current.Response.BinaryWrite (renderedBytes);
Same code for v1 and v2
public class InformeVentas : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
LocalReport localReport = new LocalReport
{
ReportPath = HttpContext.Current.Server.MapPath("~/Informes/InformeVentas.rdlc")
};
List<TablaEvolucionValorAnterior> listaPolizas = DatosGrafica.GetTablaEvolucionPolizasVentas(Convert.ToInt32(context.Request["empresa"]), Convert.ToInt32(context.Request["mediador"]));
ReportDataSource reportDataSourcePolizas = new ReportDataSource("TablaEvolucionVentasPolizas", listaPolizas);
localReport.DataSources.Add(reportDataSourcePolizas);
List<TablaEvolucionValorAnterior> listaPrimas = DatosGrafica.GetTablaEvolucionPrimasVentas(Convert.ToInt32(context.Request["empresa"]), Convert.ToInt32(context.Request["mediador"]));
ReportDataSource reportDataSourcePrimas = new ReportDataSource("TablaEvolucionVentasPrimas", listaPrimas);
localReport.DataSources.Add(reportDataSourcePrimas);
List<TablaRamosVentas> listaRamos = DatosGrafica.GetTablaRamosVentas(Convert.ToInt32(context.Request["empresa"]), Convert.ToInt32(context.Request["mediador"]));
ReportDataSource reportDataSourceRamos = new ReportDataSource("TablaRamosVentas", listaRamos);
localReport.DataSources.Add(reportDataSourceRamos);
List<ReportParameter> parameters = new List<ReportParameter>
{
new ReportParameter("FechaDatos", DatosGrafica.GetFechaActualizacionDatos().ToShortDateString())
};
localReport.SetParameters(parameters);
Informe.GeneraInforme((TipoSalida)Convert.ToInt32(context.Request["tipoSalida"]), localReport, "InformeVentas");
}
public static void GeneraInforme(TipoSalida tipoSalida, LocalReport localReport, string tituloInforme)
{
string reportType = tipoSalida.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 (tipoSalida)
{
case TipoSalida.Pdf:
HttpContext.Current.Response.ContentType = "application/pdf";
break;
case TipoSalida.Excel:
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
break;
}
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" + tituloInforme + "." + fileNameExtension);
HttpContext.Current.Response.BinaryWrite(renderedBytes);
HttpContext.Current.Response.End();
}
Any suggestions for troubleshooting? it is a production environment.
Update
TODO: You can investigate the troubleshooting by using configurable CAS security settings in open the AppDomain application directly in the original application and execute a very simple AppDomain disposal policy to contain memory leaks. For more information, please refer to Vladimir's workaround in this thread Slow performance with dynamic grouping and ReportViewer in local mode
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/6d89e2ce-3528-465f-9740-7e22aa7b7aae/slow-performance-with-dic-grouping-and-reportviewer-in-local-mode? forum = sqlreportingservices
I am trying this:
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/6d89e2ce-3528-465f-9740-7e22aa7b7aae/slow-performance-with-dic-grouping-and-reportviewer-in-local-mode? forum = sqlreportingservices
https://social.msdn.microsoft.com/Forums/sqlserver/en-US/b35bf409-4d73-4506-b13b-2629b1216773/reportviewer-in-net-4-even-possible-legacycasmodeltrue-causes-problems
http://blogs.msdn.com/brianhartman/archive/2010/02/18/expression-evaluation-in-local-mode.aspx
http://connect.microsoft.com/VisualStudio/feedback/details/527451/ms-report-viewer-memory-leak-any-update-fix-winforms-application
I'm trying to
var sec=new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);
localReport.SetBasePermissionsForSandboxAppDomain(sec);
and localReport.ReleaseSandboxAppDomain
but in a production environment I get the same error OutOfMemory
.
No one has answered this question yet
See similar questions:
or similar: