Click here to Skip to main content
Rate this: bad
good
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 at 3-May-12 2:46am
   
What's Rpt?
Member 8861818 at 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 at 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
0 Sergey Alexandrovich Kryukov 690
1 Dnyaneshwar@Pune 540
2 ravikhoda 325
3 OriginalGriff 279
4 Manas Bhardwaj 230
0 Sergey Alexandrovich Kryukov 10,974
1 OriginalGriff 6,777
2 Peter Leow 4,785
3 Abhinav S 3,813
4 Maciej Los 3,575


Advertise | Privacy | Mobile
Web04 | 2.8.140421.2 | Last Updated 3 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid