Application Pools was stopped

Topics: Administration, Writing modules
Mar 26, 2012 at 10:22 AM

When I try to generate an EditViewModel of a content, which have many 1-N attributes,

 

var propertyTypeHouse = Services.ContentManager.Get<PropertyTypeHousePart>(id);

 

 
int _provinceId = propertyTypeHouse.Province != null ? propertyTypeHouse.Province.Id : 0;
int _districtId = propertyTypeHouse.District != null ? propertyTypeHouse.District.Id : 0;
int _wardId = propertyTypeHouse.Ward != null ? propertyTypeHouse.Ward.Id : 0;
int _streetId = propertyTypeHouse.Street != null ? propertyTypeHouse.Street.Id : 0;
//int _directionId = propertyTypeHouse.Direction != null ? propertyTypeHouse.Direction.Id : 0;

Everything same to be ok except when I try to get _directionId from propertyTypeHouse.Direction

the Application Pools was stopped

Do you have any idea?

 

/*
public class PropertyTypeHousePartRecord : ContentPartRecord
*/
        
// Address

public virtual LocationProvincePartRecord Province { get; set; }
public virtual LocationDistrictPartRecord District { get; set; }
public virtual LocationWardPartRecord Ward { get; set; }
public virtual LocationStreetPartRecord Street { get; set; }

// Direction

public virtual DirectionPartRecord Direction { get; set; }


/*
public class PropertyTypeHousePart : ContentPart<PropertyTypeHousePartRecord>
*/

// Address

        public LocationProvincePartRecord Province
        {
            get { return Record.Province; }
            set { Record.Province = value; }
        }
        public LocationDistrictPartRecord District
        {
            get { return Record.District; }
            set { Record.District = value; }
        }
        public LocationWardPartRecord Ward
        {
            get { return Record.Ward; }
            set { Record.Ward = value; }
        }
        public LocationStreetPartRecord Street
        {
            get { return Record.Street; }
            set { Record.Street = value; }
        }

// Direction

        public DirectionPartRecord Direction
        {
            get { return this.Direction; }
            set { this.Direction = value; }
        }

 

 

Developer
Mar 26, 2012 at 5:43 PM
Edited Mar 26, 2012 at 5:43 PM

You have an error in your code, that's causing StackOverflowException. And that crashes the apppool, obviously.

This property

 

        public DirectionPartRecord Direction
        {
            get { return this.Direction; }
            set { this.Direction = value; }
        }

 

is recurrently (and indefinitely) calling itself... I guess you forgot to add a Direction property on the record and use this.Record.Direction instead of this.Direction.

Mar 27, 2012 at 1:55 AM

Thank you very much pszmyd,

You save my day. Change this.Direction to Record.Direction solve my problem.