请问出现下面的情况是怎么回事,求解决。。谢谢
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";
如果Bean中有复杂类型如Person,而Bean中没有实例化它,那在Bean实例请求Person的属性时就空指针了。这是我曾经遇到的情形,感觉你这个也应该类似,再查查吧
第131行的这句话出错
pop = bll.GetModel(c_id).a1 + ConfigurationManager.AppSettings["url"];
出错原因是某一个对象是null
在这里应该是 bll.GetModel(c_id)的计算结果是null
接下来 你就下断点进去看看为什么会得出null就好了
初次判断应该是这里
ConfigurationManager.AppSettings["url"];
你在webConfig里边没有配置url吧。
断点跟踪一下什么地方为Null了
这段代码是看不出什么的,可能是数据层没new