CSLA SerializationException on BeginEdit when using LazyGetPropertyAsync

168 views Asked by At

Having a problem when using LazyGetPropertyAsync on a business object, I've put some code examples to show the basic structure of this issue. As soon as I call BeginEdit (After a fetch) I am getting the following SerializationException.

System.Runtime.Serialization.SerializationException: 'Type 'Csla.PropertyInfo`1[[MyApp.ChildList, MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' in Assembly 'Csla, Version=4.6.603.0, Culture=neutral, PublicKeyToken=93be5fdc093e4c30' is not marked as serializable.'

This does not happen if I replace LazyGetPropertyAsync with LazyGetProperty and then use the syncronhous method instead of the async. I also tried using LazyGetPropertyAsync< ChildList> but I still get the exception.

What am I doing wrong here?

    [Serializable]
    public class MyObject : BusinessBase<MyObject>
    {
         //readonly backing field here
         public ChildList Child
         {
             get
             {
                 return LazyGetPropertyAsync(ChildProperty, ChildList.FetchAsync());
             }
         }
    }

    [Serializable]
    public class ChildList : ReadOnlyListBase<ChildList, ChildObject>
    {
          public static ChildList Fetch()
          {
               //fetch here
          }

          public static async Task<ChildList> FetchAsync()
          {
               //fetch here
          }
    }

    [Serializable]
    public class ChildObject : ReadOnlyBase<ChildObject>
    {
         //some stuff here
    }
1

There are 1 answers

2
Andy On

I suspect this is a bug in the Csla framework, which is storing the Task<T> into the FieldManager, instead of the result of awaiting that Task<T>.