当前位置: 代码迷 >> ASP.NET >> 问一个Application的有关问题
  详细解决方案

问一个Application的有关问题

热度:4666   发布时间:2013-02-25 00:00:00.0
问一个Application的问题
C# code
private int getAdsCount(int position) {        int count = 0;        if (Application["pos_" + position] == null)   // 总是提示此行未将对象引用设置到对象。        {            SqlParameter[] param = {               new SqlParameter("@ChannelID",SqlDbType.Int,4),              new SqlParameter("@AreaID",SqlDbType.Int,8),              new SqlParameter("@CategoryID",SqlDbType.Int,8),              new SqlParameter("@CategoryB",SqlDbType.Int,8),              new SqlParameter("@PositionID",SqlDbType.BigInt,8)        };            param[0].Value = 4;            param[1].Value = AreaID;            param[2].Value = CategoryID;            param[3].Value = CategoryB;            param[4].Value = position;            DataSet ds = PubPage.Common.SqlHelper_V1.ExecuteDataset(conn, CommandType.StoredProcedure, "sp_GetAdList", param);            count = ds.Tables[0].Rows.Count;            Application.Lock();            Application["pos_" + position] = count;            Application.UnLock();        } else {           count = Convert.ToInt32(Application["pos_" + position].ToString());        }        return count;    }



Application这里应该怎么用?

------解决方案--------------------------------------------------------
Application是NULL了。getAdsCount函数是在什么类里面?
------解决方案--------------------------------------------------------

if (System.Web.HttpContext.Current.Application["pos_" + position] == null)

------解决方案--------------------------------------------------------
没有获取到 Application对象.
  相关解决方案