使用LazyGetPropertyAsync时

时间:2017-11-30 16:53:35

标签: .net asynchronous serialization business-objects csla

在业务对象上使用LazyGetPropertyAsync时出现问题,我已经提供了一些代码示例来说明此问题的基本结构。一旦我调用BeginEdit(获取后),我就会收到以下SerializationException。

  

System.Runtime.Serialization.SerializationException:'Type   'Csla.PropertyInfo`1 [[MyApp.ChildList,MyApp,Version = 1.0.0.0,   在Assembly'Csla中,Culture = neutral,PublicKeyToken = null]]',   Version = 4.6.603.0,Culture = neutral,PublicKeyToken = 93be5fdc093e4c30'   没有标记为可序列化。'

如果我将LazyGetPropertyAsync替换为LazyGetProperty,然后使用syncronhous方法而不是async,则不会发生这种情况。我也尝试过使用LazyGetPropertyAsync<的childList>但我仍然得到例外。

我在这里做错了什么?

    [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 个答案:

答案 0 :(得分:0)

我怀疑这是Csla框架中的一个错误,它将Task<T>存储到FieldManager中,而不是等待Task<T>的结果。