2012-05-02

PropertyData object with name "FooBar" already exists


I ran into this during the weekend while I did some work from home. The site I was working on is running EPi6r2 with PageTypeBuilder and I was just adding a couple of new properties for a page type when I suddenly and unexpectedly got the yellow screen of death exception message thrown a me. I couldn't access any page, nor the edit or admin modes.

Googling a little, there was some talk on forums and blogs about the problem being related to language handling and such but none of the things I found applied to my situation.

...so I started tracing the origin of the exception back through Reflector and ended up in EpiServer.Core.PropertyDataCollection:

public void Add(string name, PropertyData value)
{
    this.InternalApproveObject(name, value);
    if (base.BaseGet(name) != null)
    {
        throw new ApplicationException("PropertyData object with name \"" + name + "\" already exists");
    }
    value.Parent = this;
    base.BaseAdd(name, value);
}

EPi, rightfully I might add, detected that I had added more than one property with the same name. (On a side note, I can think of a bunch of more pleasant behaviors to handle property doublets than to just throw an Application Exception; use the first (lowest id) and automatically remove the clones, rename the clones using a prefix or suffix, etc.). How could I add several properties with the same name on the same page type? To be honest I'm not exactly sure but I think this is what might have happened:

First off, at the time I was on a fairly slow Wifi connection, running the site locally but connecting it to a remote database over VPN. The fact that, after compiling. I hit the reload button in Chrome for both the site, edit mode and admin mode in three different tabs pretty much at the same time probably also contributed since, iirc, they each run as a separate application. Delays in contact with SQL probably enabled PTB to insert multiple copies of the same property from the different applications in question.

Once I figured this out it was easy enough to manually edit out doublets from tblPageDefinition in the database and the site would work as expected again.

3 comments:

  1. Hi,

    I've had the same problem a couple of times and came to the same conclusion. Just an FYI that admin mode is still up and running so if you don't/can't access sql easily then you can still remove the duplicate through the EPiServer UI.


    Cheers, Chris.

    ReplyDelete
  2. Hello Chris,

    Thanks for your input!

    I'm not sure anymore but I believe I got the exception in the tab where I had admin mode loaded as well, though of course, I could be mistaken.

    Shouldn't a PropertyDataCollection be created for each page type (detect duplicate properties in the process and throwing an exception) when starting up admin mode as well?

    If not, it would without a doubt much more convenient to remove the doublets through admin mode.

    ReplyDelete
    Replies
    1. I believe you! I've just had this same error and my whole site went down and no access to admin mode. So into the database I go.....!

      Thanks guys.

      Delete