错误:无法计算表达式 [英] Error: Unable to evaluate expression

查看:102
本文介绍了错误:无法计算表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在asp.net中遇到以下异常:无法评估表达式,因为代码已优化或本机框架位于调用堆栈的顶部

调用Rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, " Summary Report");
时 btn click事件的方法.

所以在执行此语句后btnExcel.Enabled=true;不执行;
或者如果我在finally块中写btnExcel.Enabled=true;,那么也不会执行.

任何想法

我的代码是这样的,

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;

}

推荐答案

我对此顺序表示怀疑.
I doubt this sequence.
Rpt.Dispose();
Rpt.Close();


使其反转


Make it reverse

Rpt.Close();
Rpt.Dispose();


这篇关于错误:无法计算表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆