0

Im currently using N2CMS to create a website however I am having the below issue.

I have a page where I have a list of images:

[EditableChildren("SliderImageItem", "SliderImageItem", 150)]
    public virtual IList<SliderImageItem> SliderImages
    {
        get
        {
            return GetChildren<SliderImageItem>("SliderImageItem");
        }
    }

The code for the SliderImageItem:

[PartDefinition("Image", Description = "", SortOrder = 0)]
[AllowedZones("SliderImageItem")]
public class SliderImageItem : N2.ContentItem, IPart
{
    public string Summary
    {
        get { return ""; }
    }

    public override bool IsPage
    {
        get { return false; }
    }

    public virtual string getLargeImage
    {
        get { return N2Helper.getLargeImage(SliderImage); }
    }

    [FileAttachment, EditableFileUploadAttribute("Slider Image", 50)]
    public virtual string SliderImage
    {
        get { return (string)GetDetail("SliderImage") ?? string.Empty; }
        set { SetDetail("SliderImage", value, string.Empty); }
    }
}

My issue is that whenever I create a page and add the item immediately, it throws a StackOverflowException, which probably means there is an infinite loop somewhere. The strange thing is that when I first save the item and then go back to add the image list item, it works. Could it be cause the page doesnt yet have an ID and does not have a reference to bind it with?

I have looked and also made reference from the Github project with little luck. Is there something I am missing?

Thanks for any help.

Andrei0427
  • 573
  • 3
  • 6
  • 18
  • if you comment out this line `set { SetDetail("SliderImage", value, string.Empty); }` does it still throw exception? – Valentin Sep 18 '16 at 13:42
  • @Valentin I just tried it, it doesnt, instead it sends me to the 'Edit' page of the homepage where I have another list collection... 0_o – Andrei0427 Sep 18 '16 at 13:49
  • this can also create an infinite loop: get { return N2Helper.getLargeImage(SliderImage); }. Did you check the callstack? – rlee Sep 18 '16 at 14:24
  • Infinite recursive calls can easily lead to `StackOverflowException`, dump the Stack trace to understand what's going wrong – Mrinal Kamboj Sep 18 '16 at 15:04

0 Answers0