简体   繁体   中英

ExportToHttpResponse is not responding after using try catch in IIS

ExportToHttpResponse is giving error: “Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack.” After using Try Catch it is working Fine in debug ... but after published in IIS it is giving error without try catch and if i use try catch it doesnt respond.. pdf file doesnt download. nothing happens.. I need help...

protected void Link4_Click(object sender, EventArgs e)
{
    crystalReport = obj.CRDirectory(Server.MapPath(@"CrystalReport\MembersDirectory.rpt"));
    Response.Buffer = false;
    Response.ClearContent();
    Response.ClearHeaders();
    try 
    {                 
        crystalReport.ExportToHttpResponse(
          ExportFormatType.PortableDocFormat,      
          Response, true, "MembersDirectory"); 
    }
    catch (Exception ex) { }       
}`

I searched a lot on internet but i did not find anything that worked.

Try This way.

ReportDocument crystalReport = new ReportDocument();    
crystalReport.Load(Server.MapPath("MembersDirectory.rpt"));
Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
 try
 {
        crystalReport.ExportToHttpResponse(
          ExportFormatType.PortableDocFormat,
          Response, true, "MembersDirectory");
    }
    catch (Exception ex) {

    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM