的InnerException =无法评估前pression因为code优化或本机框架是在调用堆栈的顶部 [英] InnerException = Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

查看:224
本文介绍了的InnerException =无法评估前pression因为code优化或本机框架是在调用堆栈的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的code是

请给我的解决方案...谢谢

please give me solution...thank you

  bool b = false;
  string str=Server.MapPath("~/Files/"+filepath);


      //  Send the file to the browser
      Response.AddHeader("Content-type", filetype);
      Response.AddHeader("Content-Disposition", "attachment; filename=" + filename);

      Response.TransmitFile(Server.MapPath("~/Files/" + filepath));


      Response.Flush();
      //  HttpContext.Current.ApplicationInstance.CompleteRequest();
       Response.End();

      b = true;


推荐答案

这个通知表示线程正在执行code和因此不能用于评估前pression

This notification means that the thread is currently executing code, and therefore cannot be used to evaluate the expression.

使用

 HttpContext.Current.ApplicationInstance.CompleteRequest 

而不是到Response.End()的;

Response.Flush 到Response.End 除了做同样的事情到Response.End 停止页的执行,并引发 EndRequest 事件。

Response.Flush and Response.End does the same thing except Response.End stops execution of the page, and raises the EndRequest event.

调用到结束方法抛出当电流响应结束prematurely一个 ThreadAbortException 例外。

Calls to the End methods throw a ThreadAbortException exception when the current response ends prematurely.

这篇关于的InnerException =无法评估前pression因为code优化或本机框架是在调用堆栈的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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