未将对象引用设置到对象的实例,求解解决思路
未将对象引用设置到对象的实例,求解
这是一个列表页面的分页?page=xx, 第一页全部正常,但有的分页打不开,报这个错,求大神指点
[NullReferenceException: 未将对象引用设置到对象的实例。]
OblogNT.Web.message.Page_Load(Object sender, EventArgs e) +185
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
以下是相关.cs
namespace OblogNT.Web
{
using OblogNT.Common;
using OblogNT.Core;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
public class message : Page
{
private string _url = string.Empty;
protected Literal msg;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected void Page_Load(object sender, EventArgs e)
{
if (RequestUtils.Get("url").Length == 0)
{
this._url = (base.Request.UrlReferrer == null) ? null : base.Request.UrlReferrer.ToString();
}
else
{
this._url = RequestUtils.Get("url");
}
if (this._url == null)
{
this._url = BlogInfo.BlogUrl + "default.aspx";
}
string str = RequestUtils.Get("msg");
this.msg.Text = str;
}
protected string url
{
get
{
return this._url;
}
set
{
this._url = value;
}
}
}
}
------解决方案--------------------
要不是空值,要不是空对象~~debug下啊
------解决方案--------------------
无非就是这里面某个变量为null。具体哪一行你又不说,自己调试都懒得做,让人家帮你一行一行看你觉得可能么。
------解决方案--------------------
按键盘F11调试看错在哪
------解决方案--------------------
应该是你指定的页面没有数据
------解决方案--------------------
在 protected void Page_Load(object sender, EventArgs e)里设个断点,运行后,按F10单步执行,看每行结果,有没有空值……。
这是一个列表页面的分页?page=xx, 第一页全部正常,但有的分页打不开,报这个错,求大神指点
[NullReferenceException: 未将对象引用设置到对象的实例。]
OblogNT.Web.message.Page_Load(Object sender, EventArgs e) +185
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
以下是相关.cs
namespace OblogNT.Web
{
using OblogNT.Common;
using OblogNT.Core;
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
public class message : Page
{
private string _url = string.Empty;
protected Literal msg;
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
}
protected void Page_Load(object sender, EventArgs e)
{
if (RequestUtils.Get("url").Length == 0)
{
this._url = (base.Request.UrlReferrer == null) ? null : base.Request.UrlReferrer.ToString();
}
else
{
this._url = RequestUtils.Get("url");
}
if (this._url == null)
{
this._url = BlogInfo.BlogUrl + "default.aspx";
}
string str = RequestUtils.Get("msg");
this.msg.Text = str;
}
protected string url
{
get
{
return this._url;
}
set
{
this._url = value;
}
}
}
}
------解决方案--------------------
要不是空值,要不是空对象~~debug下啊
------解决方案--------------------
无非就是这里面某个变量为null。具体哪一行你又不说,自己调试都懒得做,让人家帮你一行一行看你觉得可能么。
------解决方案--------------------
按键盘F11调试看错在哪
------解决方案--------------------
应该是你指定的页面没有数据
------解决方案--------------------
在 protected void Page_Load(object sender, EventArgs e)里设个断点,运行后,按F10单步执行,看每行结果,有没有空值……。