无法评估表达式,因为代码已优化或本机帧位于调用之上 [英] Unable to evaluate expression because the code is optimized or a native frame is on top of the call

查看:77
本文介绍了无法评估表达式,因为代码已优化或本机帧位于调用之上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int index = Convert.ToInt32(e.CommandArgument);
                   string path = "select FileData,extension,upload_filename,contentType from ImprestExpenseDetails where BillNo='" + index + "'";
                   DataSet ds = new DataSet();
                   ds = objcBLL.GetQueryResult(path, "ImageView");
                   if (ds.Tables["ImageView"].Rows.Count > 0)
                   {
                       Byte[] bytes = (Byte[])ds.Tables["ImageView"].Rows[0]["FileData"];
                       string extension = (string)ds.Tables["ImageView"].Rows[0]["extension"];
                       string filename = (string)ds.Tables["ImageView"].Rows[0]["upload_filename"];
                       string contenttype = (string)ds.Tables["ImageView"].Rows[0]["contentType"];

                       if (extension == ".pdf")
                       {
                           string fpath = Server.MapPath("~/" + filename);
                           Response.Buffer = true;
                           Response.Charset = "";
                           Response.Cache.SetCacheability(HttpCacheability.NoCache);
                           Response.ContentType = contenttype;
                           Response.AddHeader("content-disposition", "attachment;filename=" + filename);
                           Response.BinaryWrite(bytes);
                           Response.Flush();
                           Response.End();
                       }


                       if (extension == ".jpg")
                       {

                       }
                   }





我尝试了什么:



我收到了Response的错误。结束()

i使用HttpContext.Current.ApplicationInstance.CompleteRequest();在使用此错误后,Response.End();

已解决,但未下载文件。

请帮助



What I have tried:

I got the error on Response.End()
i use HttpContext.Current.ApplicationInstance.CompleteRequest(); inplace of Response.End();
after using this error is resolved but file is not downloaded.
Please help

推荐答案

如果你收到一条你不明白的错误信息,谷歌吧:

无法评估表达式,因为代码已经过优化或者原始框架位于通话之上 - Google搜索 [ ^ ]

如您所见,您不是第一个遇到此问题的人。

开始查看一些链接,你会发现: asp.net - Response.End(抛出错误 - 堆栈溢出 [ ^ ]这可能是同样的问题(和解决方案)。

Response.End旨在终止页面 - 所以如果你同时进行同步下载,然后是的,它可能会终止它。
If you get an error message you don't understand, Google it:
Unable to evaluate expression because the code is optimized or a native frame is on top of the call - Google Search[^]
As you can see, you aren't the first to have this problem.
Start looking at some of the links, and you will find this: asp.net - Response.End() throwing an Error - Stack Overflow[^] which is probably the same problem (and a solution).
Response.End is designed to terminate a page - so if you have an synchronous download going at the same time, then yes, it will probably terminate it.


这篇关于无法评估表达式,因为代码已优化或本机帧位于调用之上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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