Error after trying to delete category?

Nov 5, 2008 at 11:33 PM
I logged onto my website and tried to delete a category. After clicking the delete option for this category i recieved the following. Now every time I log into my blog an dtry to select the admin link categories this error message appears:

 

Server Error in '/thomas_bosscher' Application.

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:

Line 184:			return "";
Line 185:		else
Line 186: return Category.GetCategory((Guid)temp.Parent).Title;Line 187:	}
Line 188:}

Source File: d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx.cs    Line: 186

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
   admin_Pages_Categories.GetParentTitle(Object item) in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx.cs:186
   ASP.admin_pages_categories_aspx.__DataBind__control16(Object sender, EventArgs e) in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx:40
   System.Web.UI.Control.OnDataBinding(EventArgs e) +99
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +206
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +204
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.Control.DataBindChildren() +204
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +216
   System.Web.UI.Control.DataBind() +12
   System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) +221
   System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +2957
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +59
   System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) +11
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +111
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +29
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +149
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +70
   System.Web.UI.WebControls.GridView.DataBind() +4
   admin_Pages_Categories.BindGrid() in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx.cs:177
   admin_Pages_Categories.Page_Load(Object sender, EventArgs e) in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx.cs:24
   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


Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433


Anyone have any ideas how to clear this error? Is this a bug?

Thanks in advance,

Thomas Bosscher
<!-- [NullReferenceException]: Object reference not set to an instance of an object. at admin_Pages_Categories.GetParentTitle(Object item) in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx.cs:line 186 at ASP.admin_pages_categories_aspx.__DataBind__control16(Object sender, EventArgs e) in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx:line 40 at System.Web.UI.Control.OnDataBinding(EventArgs e) at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at System.Web.UI.Control.DataBind() at System.Web.UI.Control.DataBindChildren() at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at System.Web.UI.Control.DataBind() at System.Web.UI.Control.DataBindChildren() at System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) at System.Web.UI.Control.DataBind() at System.Web.UI.WebControls.GridView.CreateRow(Int32 rowIndex, Int32 dataSourceIndex, DataControlRowType rowType, DataControlRowState rowState, Boolean dataBind, Object dataItem, DataControlField[] fields, TableRowCollection rows, PagedDataSource pagedDataSource) at System.Web.UI.WebControls.GridView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) at System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.GridView.PerformDataBinding(IEnumerable data) at System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) at System.Web.UI.WebControls.DataBoundControl.PerformSelect() at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at System.Web.UI.WebControls.GridView.DataBind() at admin_Pages_Categories.BindGrid() in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx.cs:line 177 at admin_Pages_Categories.Page_Load(Object sender, EventArgs e) in d:\hosting\thomasbosscher\thomas_bosscher\admin\Pages\Categories.aspx.cs:line 24 at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) at System.Web.UI.Control.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.admin_pages_categories_aspx.ProcessRequest(HttpContext context) in c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\thomas_bosscher\a586465c\8d582099\App_Web_kfoxoi8j.0.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) --><!-- This error page might contain sensitive information because ASP.NET is configured to show verbose error messages using <customErrors mode="Off"/>. Consider using <customErrors mode="On"/> or <customErrors mode="RemoteOnly"/> in production environments.-->
Nov 26, 2008 at 2:41 AM
I just did this same thing. Did you find a fix for it? Please let me know.

Thanks!
Apr 6, 2009 at 2:03 PM
We are getting the very same error on v 1.4.5.0. Last week I showed one of our users how to use categories, and today I saw that she had added some new ones. Only problem is that now I'm unable to get to the categories page at all, throwing the same error as above. No idea what she did, but she has no access to anything on the site or server except via the browser interface.

Can I manually add back the categories I had before she messed with it? I have full access to the server "back side". Better of course is a fix or reason why this is happening.

TIA

elaine
charlottesville, va
Coordinator
Apr 6, 2009 at 6:18 PM
Probably a category was setup as a "parent" category of another category.  Then the parent category was deleted -- leaving the child category with no parent.

You can go directly into the categories.xml file in the App_Data folder and clean things up.  If you make any manual changes in that file, in order to get BE to recognize the changes, you'll need to restart the blog.  You can do this by overwriting the Web.config file with itself, or just add a space in the Web.config file.
Apr 6, 2009 at 6:34 PM
Ah, that's possible. These were test ones I'd set up somewhile back, and probably at least one had a parent. I'll bet she DID remove them improperly, but heck, I didn't know that either :)

I can edit the xml file, but what about the ID values? Can I ignore them? Use something else? Luckily we have a second site where I can at least get the syntax.

Thanks!

elaine
Coordinator
Apr 6, 2009 at 6:43 PM
As you said, you could just overwrite the categories.xml file with one that does work.  If you were to edit the existing categories.xml file, you would want to change the "parent" to an empty string if the ID for the parent doesn't exist.

If you're not familiar with the organization of the categories.xml file, then it's probably simplest to just overwrite that file with a good file.  Then re-start the blog.
Apr 6, 2009 at 6:45 PM
Aha! Fixed! I had gone into the xml file earlier and removed the reference to the bad category, but nothing had changed. However, I stupidly missed your instruction to reload the web.config file, so did that, and voila! The page now comes up just fine!

THANK YOU!!!

Cheers!

elaine