CSLA 3.6 child collection error "Property load or set failed for property Sizes (One or more properties are not registered for this type)"

CSLA 3.6 child collection error "Property load or set failed for property Sizes (One or more properties are not registered for this type)"

Old forum URL: forums.lhotka.net/forums/t/7128.aspx


Harry_Seldon posted on Wednesday, June 17, 2009


Hi All,

I'm haveing an issue with a child collection.
I'm getting the error "Property load or set failed for property Sizes (One or more properties are not registered for this type"

 

My property declaration in the parent is:

private static PropertyInfo<Sizes> SizesProperty = RegisterProperty<Sizes>(typeof(Sizes), new PropertyInfo<Sizes>("Sizes"));

 

Trying to load the Sizes child collection in DataPortal_Fetch of the parent.

LoadProperty<Sizes>(SizesProperty, Sizes.GetSizes(repository));

 

The Sizes object is pretty straight forward and has no properties at all.

[Serializable()]

    public class Sizes : Csla.BusinessListBase<Sizes, Size>

    {

 

BTW generated with codesmith 3.6 templates.

 

The Size class also generated with codesmith templates, has only two properties.

 

[Serializable()]

    public class Size : Csla.BusinessBase<Size>

    {

        #region Business Properties and Methods

        //register properties

        private static PropertyInfo<int> IdProperty = RegisterProperty<int>(typeof(Size), new PropertyInfo<int>("Id"));

        private static PropertyInfo<string> DescriptionProperty = RegisterProperty<string>(typeof(Size), new PropertyInfo<string>("Description"));

 

The data is fetched from the child, but the LoadProperty in the parent fails with the error as above and I just don't know what it really means. The object Sizes has no properties, so I don't know what the error is referring to.


I'm using CSLA 3.6.3

Any insight would be great. By the way I do have the Business objects 2008 book. I didn't find any help in there.


Thanks in advance.



JoeFallon1 replied on Thursday, June 18, 2009

I think that message used to appear a lot whenever there was a problem with the managed properties getting "out of alignment". There was a forceInit static variable trick that was used to ensure that all the register property statements occurred. Without it there was no guarantee that all of the properties would register and you would get that message.

The odd thing is that Rocky fixed that issue in CSLA 3.6.2 or thereabouts and eliminated the need for forceInit. So if you are running 3.6.3 you should not be seeing this. Maybe something else is incorrect about the way you are registering properties.

Joe

Harry_Seldon replied on Friday, June 19, 2009

Thanks Joe, just the hint I needed.
I started playing around with the register code, eventually this seems to work

New:
private static PropertyInfo<Sizes> SizesProperty = RegisterProperty<Sizes>(new PropertyInfo<Sizes>("Sizes"));

Old - difference is bold:
private static PropertyInfo<Sizes> SizesProperty = RegisterProperty<Sizes>(typeof(Sizes), new PropertyInfo<Sizes>("Sizes"));

Thanks again.

Copyright (c) Marimer LLC