错误:无法评估前pression因为code优化 [英] Error: Unable to evaluate expression because the code is optimized

查看:253
本文介绍了错误:无法评估前pression因为code优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到一个错误在我的asp.net应用程序读取

I am getting an error in my asp.net app that reads

无法因为code优化或本机框架是在调用堆栈的顶部,以评估前pression。

protected void btnCustomerProfile_Click(object sender, EventArgs e)
{
    try
    {
        Server.Transfer("CustomerProfile.aspx");
    }
    catch (Exception ex)
    {
        Response.Write(ex.ToString());
    }
    finally
    { }
}

SO搜索后,我看到大部分的同类职位涉及的Response.Redirect。我的code使用的Server.Transfer和我的应用程序也在使用母版页。

After searching SO, I see most of the similar posts involve response.redirect. My code is using server.transfer and my application is also using Master Pages.

我怎样才能解决这个问题?

How can I resolve this issue?

更新:由于某些原因,出现此错误是我使用Response.Redirect的为好。不幸的是我不能使用使用Server.Execute,因为使用Server.Execute调用调用页面接近尾声。

Update: For some reason, this error occurs is I use Response.Redirect as well. Unfortunately I cannot use Server.Execute, because Server.Execute calls the calling page towards the end.

推荐答案

您将得到一个错误,但低于意志陷阱code座它,你可以用你的生活。

You will get an error, but the code block below will trap it and you can get on with your life.

试试这个:

using System.Threading.ThreadAbortException;

catch(ThreadAbortException ex)
{
    throw;
}

这篇关于错误:无法评估前pression因为code优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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