OutOfMemoryException using RDLC, LocalReport, Micr

2019-06-04 13:04发布

In my Production environment, in THE SAME IIS Server, I have 2 applications

v1 App, vS 2008 , .NET 3.5 ) , https://server/v1/Ventas.aspx Works fine using Local Report (RDLC)

v2 App (VS 2012, .NET 4.5.1) (https://server/v2/Ventas.aspx gets OutOfMemoryException error 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:Started). Account: ApplicationPoolIdentity. ( I try too with NETWORK SERVICE)

I dont know which is the problema: IIS config, pool, site, web.config, HttpContext.Current.Response.BinaryWrite(renderedBytes);??

The 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 Production environment.

Updated

TODO: investigate troubleshooting can custom CAS security settings in separated AppDomain directly in original application, and implement a very simple AppDomain recycle policy just 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-dynamic-grouping-and-reportviewer-in-local-mode?forum=sqlreportingservices

I try this:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/6d89e2ce-3528-465f-9740-7e22aa7b7aae/slow-performance-with-dynamic-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 try

var sec=new System.Security.PermissionSet(System.Security.Permissions.PermissionState.Unrestricted);

localReport.SetBasePermissionsForSandboxAppDomain(sec);

and localReport.ReleaseSandboxAppDomain

but in Production Environment, I gets the same error OutOfMemory.

0条回答
登录 后发表回答