Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Søren Løhr 7 posts 25 karma points
    Jan 10, 2012 @ 16:31
    Søren Løhr
    0

    'Sequence contains more than one element' when calling getProperty

    On a website running Umbraco 4.7.0, I sometimes get an error that puzzles me...

    It happens when trying to get the "text"-property of a document by excuting this code:

    var property = document.getProperty("text");

    This code is executed quite often, so the error is in no way frequent, but twice in ten days now this has thrown a 'Sequence contains more than one element' exception like this:

    [InvalidOperationException: Sequence contains more than one element]
       System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +6383080
       umbraco.cms.businesslogic.Content.getProperty(PropertyType pt) +137


    The problem is fixed by republishing the document, but I can't figure out how it can happen. Has anybody encountered something similar, and maybe found a way around it or know how it can occur?

    Any input is welcome.

  • awm 187 posts 376 karma points
    Jan 10, 2012 @ 17:39
    awm
    0

    Don't you have to use document.getProperty("text").Value ?

  • Søren Løhr 7 posts 25 karma points
    Jan 11, 2012 @ 13:52
    Søren Løhr
    0

    Yes. The line is followed by

    if (property == null)
     return "";
    return property.Value.ToString();

    and that's the end of the method that should return the text. The exception must come from inside either .getProperty or .Value...

  • awm 187 posts 376 karma points
    Jan 11, 2012 @ 13:56
    awm
    0

    EDIT: nevermind ;)

Please Sign in or register to post replies

Write your reply to:

Draft