Skip to content

Unable to evaluate expression because the code is optimized

chaithu morampudi

Asked Apr 13, 2012, 2:53 AM EDT1 answer
Share
LinkedInX
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack  while port the gridview data into msexcel

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Senthilkumar
    0
    Hi Chaithu,

    You can do like this.

    Response.Redirect("~/Error.aspx?ErrorMsg = " + ex.Message,false);

    Or you can do like this

    Code
    catch (System.Threading.ThreadAbortException lException)
    {
    
    
    // do nothing
    
    
    }



    Usually if you use this then it will not throw this exception.

    C#
    string rredirectUrl="";
    try
    {
       //Code
       redirectUrl="PaymentReceived.aspx";
    }
    catch(Exception ex)
    {
       redirectUrl="error.aspx"
    }
    Response.Redirect(redirectUrl);
    0