Friday, January 27, 2012

EPiServer custom property settings and blowing up the database

So property settings was added to PTB 2.0, and i decided to play around a bit with it and not just change the tinymce settings due to that being boring as ****. When doing so i stumbled across a.. can we say interesting "feature" of EPiServer.

What you normally do is create a settings class that inherits EPiServer.Core.PropertySettings.PropertySettingsBase (or implement the interface) and add the attributes etc. In this class you have your property settings which are serialized and stored in the dds by episerver. Now this is all fine and dandy for primitives and lists of primitives.

Now what I was doing is making a type restricted page picker, so I needed to store a list of types (ptb page types to be more specific). So ofcourse I started by adding a property:
public List<type> AvailablePageTypes { get; set; }

This will make your entire site crash and the only way to fix it is to enter the database and set the "settingsID" value to NULL for the property you decorated with the settings attribute, and also remove a bunch of lines from the tblBigTable... tables.

Apparently EPiServer has no qualms whatsoever to add invalid data/configuration to the DDS, but when you try to do anything with it the entire site is held hostage by DDS exceptions, fun times.

So when making property settings: Make sure any property you place in the settings class has a public parameterless constructor, or you kill your site. You cant even decorate properties with anything to make them not get serialized by EPiServer, any such things are ignored apparently.

I'm not even gonna start on what you have to do if you want to change the type or remove a property on a setting class (hint: Site doesn't work anymore if you do).

No comments :

Post a Comment