Saturday, March 26, 2016

Sitecore Entity Service - Stack Overflow Exception

There is a very fine print in Sitecore Entity Service documentation available here as mentioned below

Note that an entity cannot contain a property of a type that is derived from Sitecore.Services.Core.Model.EntityIdentity.

There may be more behind this statement based on my experiment with entity service.

In one of my entity service the entity I was implementing, inheriting from EntityIdentity, I had list of weekdays selected by the end user and I used Days of week list to avoid creating my own list of items. Property looked like this

        private List<Item> _daysOfWeek;
        public List<Item> DaysOfWeeks
                if (_daysOfWeek == null)
                    _daysOfWeek = new List<Item>();
                return _daysOfWeek;
            set { _daysOfWeek = value; }

Item could be any other Sitecore Item (system defined OR your own)

Now from my page code javascript when my entity service is trying to fetch an entity, it is not even hitting the FindById method of my repository inheriting from
and the worker process crashes by throwing stack overflow exception.

Finally, I had to create my own class having itemId, itemName and certain other properties as a POCO class and had to write my own transformation logic to and from Sitecore items to my this entity. This resolved the problem

Hope this will help other people working on Sitecore Entity Service and facing StackOverflowException crashing their worker process (w3wp.exe)

No comments:

Post a Comment