由于代码被伪造,因此无法评估表达式 [英] Unable to evaluate expression because the code is optomized

查看:72
本文介绍了由于代码被伪造,因此无法评估表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...
我有一些得到异常的代码由于代码已优化或本机框架位于调用堆栈的顶部,因此无法评估表达式.我在下面粘贴了一些代码.

Hi...
I have some code that gets the exception Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack. I have pasted some code below.

string strAddress = string.Empty;
            string cusomerCode =  string.Empty;
           
            cusomerCode = Request.QueryString["cCode"];
            Response.Write(cusomerCode);
            SqlConnection cn = new SqlConnection(SqlDataAccessLayer._connectionStringSales);
            SqlCommand cmd = new SqlCommand("usp_getCustomerAddress");
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@cstid", cusomerCode);
            cmd.Connection = cn;

            cn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            if (dr.HasRows == true)
            {
                 try
                 {
                   dr.Read();
                   strAddress = Convert.ToString(dr[0]) + "," + Convert.ToString(dr[2]) + "," + Convert.ToString(dr[3]) + "," + Convert.ToString(dr[4]) + "," + Convert.ToString(dr[1]) + "$";//for bill address
                   strAddress += dr[5].ToString() + "," + dr[7].ToString() + "," + dr[8].ToString() + "," + dr[9].ToString() + "," + dr[6].ToString() + "$" + dr[10] + "$";//for ship address and email
                   strAddress += dr[11].ToString() + "$";//for billing name
                   strAddress += dr[12].ToString() + "$";//for ship name
                   strAddress += dr[13].ToString() + "$";//for salesman name
                   strAddress += dr[14].ToString() + "$"+ "~";//for salesman code
                   cn.Close();
                   cmd = new SqlCommand("Select (c.BillName + '','' + c.BillAddress + '','' + ct1.cityname + '',''+ st1.statename + '','' + cn1.cntname + ''-'' + BillPincode) as Billing,(ShipName + '','' + ShipAddress + '','' + ct2.cityname + '','' + st2.statename + '','' + cn1.cntname  + ''-'' + ShpPincode) as Shipping from customer c,city ct1,state st1,country cn1,city ct2,state st2,country cn2 where ct1.citycode=c.billcity and st1.stateid=c.billstate and cn1.cntid=c.billcountry and ct2.citycode=c.shpcity and st2.stateid=c.shpstate and cn2.cntid=c.shpcountry and c.CustId=@CustID", cn);
                   cmd.Parameters.AddWithValue("@CustID", cusomerCode);
                   cn.Open();
                   dr = cmd.ExecuteReader();
                   if (dr.HasRows == true)
                   {
                       int Count = 0;
                       while (dr.Read())
                       {
                           strAddress += dr[0].ToString() + "$" + "~";//for full detail of billing
                           strAddress += dr[1].ToString();//for full detail of Shipping
                           Count++;
                       }
                       cn.Close();
                       dr.Close();
                   }
                   Response.Buffer = true;
                   Response.Clear();
                   Response.ContentType = "text/xml";
                   Response.Write(strAddress);
                   Response.End();
                   Response.Close();
                 }
                 catch (System.Threading.ThreadAbortException exc)
                 {
                     // This should be first catch block i.e. before generic Exception
                     // This Catch block is to absorb exception thrown by Response.End
                 }

                 catch (Exception ex)
                 {
                    ApplicationError.logErrors(ex);
                 }
                 finally
                 {
                    cn.Close();
                 }
            }
            else
            {
               
                Response.Clear();
                Response.ContentType = "text/xml";
                Response.Write("No");
                Response.End();
                Response.Close();
            }



我发现了这种类型的错误..



And i found this type of error..

The XML page cannot be displayed 
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later. 
--------------------------------------------------------------------------------
Invalid at the top level of the document. Error processing resource 'http://localhost:5074/newSales/getBuyer.aspx?cCode=pty...

104, Sky Line House
^

推荐答案

;//用于账单地址 strAddress + = dr [5] .ToString()+," + dr [7] .ToString()+," + dr [8] .ToString()+," + dr [9] .ToString() +," + dr [6] .ToString()+"
";//for bill address strAddress += dr[5].ToString() + "," + dr[7].ToString() + "," + dr[8].ToString() + "," + dr[9].ToString() + "," + dr[6].ToString() + "


" + dr [10] +"
" + dr[10] + "


";//收货地址和电子邮件 strAddress + = dr [11] .ToString()+"
";//for ship address and email strAddress += dr[11].ToString() + "


这篇关于由于代码被伪造,因此无法评估表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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