Click here to Skip to main content
12,349,778 members (26,581 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: ASP.NET
I am getting the following exception in asp.net: Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

When calling Rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, " Summary Report");
method on a btn click event.

so after this statement btnExcel.Enabled=true; not executed ;
or if i write btnExcel.Enabled=true; in finally block then also not executed.

Any ideas

my code is like this,
protected void btnExcel_Click(object sender, EventArgs e)
    {
           try
            {
          Rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, 
          "Summary Report");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                ex = null;
            }
          finally
              {                 
                Rpt.Dispose();
                Rpt.Close();
                }
           btnExcel.Enabled = true;
 
}
Posted 2-May-12 20:06pm
Edited 2-May-12 20:23pm
v2
Comments
Bernhard Hiller 3-May-12 2:46am
   
What's Rpt?
Member 8861818 3-May-12 3:03am
   
rpt is object of class ReportDocument .

i.e.
ReportDocument Rpt=new ReportDocument();

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I doubt this sequence.
Rpt.Dispose();
Rpt.Close();
Make it reverse
Rpt.Close();
Rpt.Dispose();
  Permalink  
Comments
Member 8861818 4-May-12 1:06am
   
i make it reverse i.e.
Rpt.Close();
Rpt.Dispose();

but still not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160621.1 | Last Updated 3 May 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100