Error "The type initializer for 'Controls.RecentPosts' threw an exception"

Topics: ASP.NET 2.0, Controls
Mar 16, 2008 at 4:54 AM
I'm getting the following error on my site. It was working and have not added any content in a weeks time :(
Running on godaddy servers

Source Error:
Line 44: int number = BlogSettings.Instance.NumberOfRecentPosts;
Line 45: Trace.Write("number : " + number);
Line 46: if (number > Post.Posts.Count)
Line 47: number = Post.Posts.Count;
Line 48:

Source File: d:\hosting\awesomeideas\App_Code\Controls\RecentPosts.cs Line: 46

Stack Trace:
NullReferenceException: Object reference not set to an instance of an object.
BlogEngine.Core.Providers.XmlBlogProvider.SelectPost(Guid id) in Posts.cs:48
BlogEngine.Core.Providers.BlogService.SelectPost(Guid id) in BlogService.cs:85
BlogEngine.Core.Post.DataSelect(Guid id) in Post.cs:700
BlogEngine.Core.Post.Load(Guid id) in Post.cs:792
BlogEngine.Core.Providers.XmlBlogProvider.FillPosts() in Posts.cs:257
BlogEngine.Core.Post.get_Posts() in Post.cs:364
Controls.RecentPosts.BuildPostList() in d:\hosting\awesomeideas\App_Code\Controls\RecentPosts.cs:46
Controls.RecentPosts..cctor() in d:\hosting\awesomeideas\App_Code\Controls\RecentPosts.cs:23

TypeInitializationException: The type initializer for 'Controls.RecentPosts' threw an exception.
Controls.RecentPosts..ctor() +0
ASP.themesawesomeideassidepanelascx._BuildControlRecentPosts1() in d:\hosting\awesomeideas\themes\awesomeideas\SidePanel.ascx:69
ASP.themesawesomeideassidepanelascx._BuildControlTree(themesawesomeideassidepanel_ascx __ctrl) in d:\hosting\awesomeideas\themes\awesomeideas\SidePanel.ascx:1
ASP.themesawesomeideassidepanel_ascx.FrameworkInitialize() in d:\hosting\awesomeideas\themes\awesomeideas\SidePanel.ascx.cs:912307
System.Web.UI.UserControl.InitializeAsUserControlInternal() +31
System.Web.UI.UserControl.InitializeAsUserControl(Page page) +14
ASP.themesawesomeideassitemaster._BuildControlInfoBox1() in d:\hosting\awesomeideas\themes\awesomeideas\site.master:38
ASP.themesawesomeideassitemaster._BuildControlform1() in d:\hosting\awesomeideas\themes\awesomeideas\site.master:13
ASP.themesawesomeideassitemaster._BuildControlTree(themesawesomeideassite_master __ctrl) in d:\hosting\awesomeideas\themes\awesomeideas\site.master:1
ASP.themesawesomeideassite_master.FrameworkInitialize() in d:\hosting\awesomeideas\themes\awesomeideas\site.master.cs:912306
System.Web.UI.UserControl.InitializeAsUserControlInternal() +31
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +2025712
System.Web.UI.Page.get_Master() +48
System.Web.UI.Page.ApplyMasterPage() +18
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +543


Mar 16, 2008 at 6:03 AM
This is resolved now
Not sure how, but 2 of the posts got reduced only to Title & Description and that was resulting in the error...
So replacing the xml files for that particular post resolved the issue.

Investigation going on how it got deleted. Could it be a bug? Not sure now!
Mar 16, 2008 at 4:48 PM


sukeshak wrote:
This is resolved now
Not sure how, but 2 of the posts got reduced only to Title & Description and that was resulting in the error...
So replacing the xml files for that particular post resolved the issue.

Investigation going on how it got deleted. Could it be a bug? Not sure now!


Initial thoughts are that GoDaddy hosting has hosed up your files. GoDaddy is notorious for providing a sub-par hosting environment.

If you do find that this is a bug in BE.N, please do post back.