The Site Doctor Blog

Footprints in the snow of a warped mind

< Back to Blog

Error when publishing Umbraco page - Object reference not set to an instance of an object

umbracologo[1]This is one of those irritating errors that you come across every now and again and can take hours to diagnose.

If you've seen something like the error at the end of this post, then check that you don't have any document types which have an alias with a non-alphanumeric character in them. If you do, remove it and all should be good.

Got lots of Umbraco Document Types and not enough time? Here's a quick script that will help find any Document Types that may be causing you trouble:

FROM [dbo].[cmsContentType] ct 
WHERE ct.alias LIKE '%[^a-zA-Z0-9]%'

Why does this happen?

Umbraco uses the "Alias" field of the Document Types to create the XML version of the site's content (you can find this in /app_data/umbraco.config) and XML cannot use anything but alphanumeric characters for it's node name (there are a couple of others that it allows but for safety it's best not to).

When you hit the "Save and Publish" button, Umbraco tries to create the XML cache, gets to your special document type and fails.

The reason it doesn't matter whether you're actually using the Document Type in the site or not is because Umbraco outputs a list of all Document Types at the start of the XML.


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.]
   umbraco.content.ValidateSchema(String docTypeAlias, XmlDocument xmlDoc) +51
      umbraco.content.AppendDocumentXml(Int32 id, Int32 level, Int32 parentId, XmlNode docXml, XmlDocument xmlContentCopy) +120
      umbraco.content.PublishNodeDo(Document d, XmlDocument xmlContentCopy, Boolean updateSitemapProvider) +217
      umbraco.content.UpdateDocumentCache(Document d) +407
      umbraco.content.UpdateDocumentCache(Int32 pageId) +75
      umbraco.library.UpdateDocumentCache(Int32 DocumentId) +150
      umbraco.cms.presentation.editContent.Publish(Object sender, EventArgs e) +462
      System.EventHandler.Invoke(Object sender, EventArgs e) +0
      umbraco.controls.ContentControl.savePublish(Object Sender, ImageClickEventArgs e) +96
      System.Web.UI.WebControls.ImageButton.OnClick(ImageClickEventArgs e) +115
      System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +120
      System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
      System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
      System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
      System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563

Author: Tim on

Liked this post? Got a suggestion? Leave a comment