Click here to Skip to main content
15,888,031 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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,
C#
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
Updated 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

I doubt this sequence.
C#
Rpt.Dispose();
Rpt.Close();

Make it reverse
C#
Rpt.Close();
Rpt.Dispose();
 
Share this answer
 
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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900