首页 新闻 会员 周边 捐助

未将对象引用到对象的实例

0
悬赏园豆:10 [已解决问题] 解决于 2013-05-28 11:40

请问出现下面的情况是怎么回事,求解决。。谢谢

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   CM.cshop.web.cmview.Page_Load(Object sender, EventArgs e) in E:\4-23\ka6商城5-28\ka6商城5-24\web\cmview.aspx.cs:131
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +91
   System.Web.UI.Control.LoadRecursive() +61
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1966

 这是源代码

 131           pop = bll.GetModel(c_id).a1 + ConfigurationManager.AppSettings["url"];
  132          if (Session["userid"] != null)
  133              pop += "cmview-" + bll.GetModel(c_id).id + "-" + int.Parse(Session["userid"].ToString()) + ".aspx";
 134           else
  135              pop += "cmview-" + bll.GetModel(c_id).id + ".aspx";

new不出对象的主页 new不出对象 | 初学一级 | 园豆:195
提问于:2013-05-24 15:00
< >
分享
最佳答案
0

如果Bean中有复杂类型如Person,而Bean中没有实例化它,那在Bean实例请求Person的属性时就空指针了。这是我曾经遇到的情形,感觉你这个也应该类似,再查查吧

收获园豆:10
寻梦丄天涯 | 菜鸟二级 |园豆:248 | 2013-05-25 01:54
其他回答(4)
0

第131行的这句话出错

pop = bll.GetModel(c_id).a1 + ConfigurationManager.AppSettings["url"];

出错原因是某一个对象是null

在这里应该是 bll.GetModel(c_id)的计算结果是null

接下来 你就下断点进去看看为什么会得出null就好了

TiestoRay | 园豆:687 (小虾三级) | 2013-05-24 15:22
0

初次判断应该是这里

 ConfigurationManager.AppSettings["url"];

你在webConfig里边没有配置url吧。

AStronghcm | 园豆:313 (菜鸟二级) | 2013-05-24 15:42
0

断点跟踪一下什么地方为Null了

chengdu.jack.li | 园豆:274 (菜鸟二级) | 2013-05-24 18:20
0

这段代码是看不出什么的,可能是数据层没new

Joevin | 园豆:230 (菜鸟二级) | 2013-05-25 00:48
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册