Problem with ModelBase and unit testing

Topics: Questions
Jan 16, 2014 at 4:08 PM
I have a class using ModelBase as the base class. I define a usertype and mark it a ExcludeFromSerialization:
        public MyType GraphObject { get; set; }
I don't serialize this class, but when I try to use it in my unit testing I get the following error:
Catel.Data.InvalidPropertyException : Property 'GraphObject' is invalid (not serializable?)

This is where the error occurs in my unit test (NUnit) when I try to instantiate the object
        public void Test()
            IGraphProperties properties = new GraphProperties();
Jan 16, 2014 at 4:10 PM
This is because in older versions of Catel, it checks whether an object contains non-serializable objects. If so, you have to define it using the [AllowNonSerializableMembers] attribute. We have changed this behavior in the upcoming version for Catel. For now, just decorate your class with the attribute.
Jan 16, 2014 at 4:27 PM
Thanks Geert