I’m just starting out with dasBlog (and blogging to as a matter of fact). dasBlog where apealing to me because there is no database needed, a real simple install. However I ran into a little problem trying to access the comments page I got an exception:
System.NullReferenceException:
Object reference not set to an instance of an object.
at newtelligence.DasBlog.Web.CommentViewBox.Page_Load(Object sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain()
Wich was wierd I toughth. So I did what you don’t want to have to do with products. I downloaded the source and started debugging. Found the error in this piece of code, in the Page_Load method of CommentViewBox.aspx.cs:
if (Request.Cookies[”email”] != null)
{
email.Text = Request.Cookies[”email”].Value;
name.Text = Request.Cookies[”name”].Value;
homepage.Text = Request.Cookies[”homepage”].Value;
}
See the problem? Just one null-check and three accesses!
When I tested the comment function for the first time I probably didn’t write anything in the hompage field. So my cookie didn’t contain tha key, hence a null access!
Addign a few more null checks solved the problem. Might be of help to someone else.
Tags: .NET Development, Blogging