SaaS CMS has officially launched! Learn more now.

Custom Property Error


Hi all,

I have a strange one and wondered if anyone had come across this before and had any advice on how to track/resolve.

I have a custom property which stores person information (name, email) so we use an object for this. This works as expected in that we can save this information against a page and retrieve it. However, occasionally, this produces an error on saving as follows:

Unable to cast object of type 'namespace.object' to type 'System.String'

With the stack trace

Stack trace:    at EPiServer.Editor.AutoSave.AutoSaveRepository.AddPropertyToDraft(PageData currentPage, Draft draft, PropertyData prop)
   at EPiServer.Editor.AutoSave.AutoSaveRepository.SavePDC(Identity draftId, PageData currentPage)
   at EPiServer.UI.Edit.AutoSaveControl.EditPanel_PreRenderComplete(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
   at EPiServer.PageBase.OnPreRenderComplete(EventArgs e)
   at EPiServer.UI.SystemPageBase.OnPreRenderComplete(EventArgs e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

So far I haven't been able to trace the cause of this and I'm a bit bemused that this only happens intermittently rather than all the time.

Any thoughts greatly appreciated,




Oct 17, 2011 10:08


In EPiServer CMS 6 R2, EPiServer added a new feature for auto-saving pages for editors. I know there are a few bugs with the background job that auto-saves (check the bug list).

I would consider turning it off by updating episerver.config and autoSaveInterval to 0:0:0 (if it's set to less than 10 seconds it is automatically turned off).

I would also contact EPiServer Support if the bug is not reported in before.


Oct 17, 2011 11:40

This is known bug

Oct 17, 2011 14:42

I'm not that sure that this has been reported before. We have a known issue in CMS 6 R2 "Auto save causes intermittent NullReferenceException in edit mode" that shares the intermittent behaivor and is in the same area but has a completely different stack trace. New bug filed for this error (#79185).

Apr 19, 2012 7:36
Apr 19, 2012 7:36


For information and if it helps with the bug investigation, setting the autoSaveInterval to 0:0:0 has prevented the issue happening.

Thanks all for your contributions,


Apr 19, 2012 10:08


After investigating this issue, the problem seems to occur when the auto save function is creating a draft version of the page to store in the DDS. When doing so, it tries to cast the value in the Value property to the corresponding type of the PropertyDataType defined in the property Type. I've updated the code to create the draft without performing the cast, and that fix will be included in any future releases.

A workaround for CMS 6 R2 is to make sure that the Value property of your custom property type returns something that is compatible with the Type property.


Per Gunsarfs
EPiServer Development Team

Apr 30, 2012 13:29

We have been hit by this same problem twice in the past two days.  The site is due for conversion to CMS7, where my reading of the above suggests that this will be will be cured.  At this stage our only cure is to revert the db to overnight back-up, losing our editors work.  We're hoping to reapply all transactions up to the hour before the event occurred.

Our stacktrace error looks like this...

[NullReferenceException: Object reference not set to an instance of an object.]
   EPiServer.Editor.AutoSave.<>c__DisplayClass5.b__4(Draft draft) +17
   System.Linq.<>c__DisplayClassf`1.b__e(TSource x) +21
   System.Linq.WhereSelectListIterator`2.MoveNext() +4226972
   System.Linq.d__88`1.MoveNext() +365

Meanwhile, is it possible to clear the db table stores references to draft pages?  If anyone has a pointer to the SQL to achieve this it would be appreciated.



Aug 26, 2014 4:45

Have you tried removing the versions that fails from the user interface?

Aug 26, 2014 7:35

Hi Linus, thanks for this idea.  I will certainly be trying to do this.

We have taken a copy of the broken database and are now looking at several things to try to rectify the problem without the need to do a DB restore.

So, I'll be diving in to this soon without the pressure that the error was occuring on a live site. 

I'm not sure how I can identify the page which is causing the Null reference.  The small part of the stack trace above doesn't lend me much clue, and in the full log it extends much further but without any page identifiable calls.  It first seems to reference an EPiSever context at this call two steps in to the full stack trace logged:


We were able to ascertain the most recent Changed page through the Admin/Reports menu.  This pointed to a page that had a 'version' that was 'Not ready'.  Deleting that version did not rectify the problem.  But I wouldn't really expect that to as 'versions' differ from 'drafts' surely.  This most recent changed page was being edited the previous day around the time the issue occurred the first time - but we haven't been able to categorically state that it was the last page changed before the issue occured.

One other thing to note is that the Admin task to "Remove draft pages" fails on the affected db (with the same/similar error), whereas it completes normally on other sites.  This is no surprise.

Is there any way you might suggest to be able to pinpoint the page whose draft is causing the issue?  What table/s in the site's EPiServer DB are worth analysis?



Aug 27, 2014 1:09

I don't have a direct answer to your questions so I suggest that you contact our support if you need further help to troubleshoot this.

Aug 27, 2014 9:07
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.