MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

netstandard BeginEdit() #580

Open tiitk opened 6 years ago

tiitk commented 6 years ago

Hello

Upgrading from 4.6 to 4.7 broke my application's beginedit. Now using netstandard, calling BeginEdit() on businessbase parent with businessbase child fails. On UWP the error says "Value cannot be null. Parameter name: format" and on Android it says something that FieldInfo[] or something like this is not serializable. What to do ?

Code to replicate is very simple:

[Serializable] public class Parent : BusinessBase { public static readonly PropertyInfo ChildProperty = RegisterProperty(c => c.Child, RelationshipTypes.Child); public Child Child { get { return GetProperty(ChildProperty); } set { SetProperty(ChildProperty, value); } }

    private void DataPortal_Fetch()
    {
        var ch = DataPortal.FetchChild<Child>();
        LoadProperty<Child>(ChildProperty, ch);
    }
}

[Serializable] public class Child : BusinessBase { private void Child_Fetch() { } }

and then call var parent = DataPortal.Fetch(); parent.BeginEdit();

michaelcsikos commented 6 years ago

I have set up a test, inheriting from BusinessBase<T>. Download it here: ClassLibrary1.zip

In Windows Forms it works, of course, but in a .NET Core console app, it throws the following:

System.InvalidOperationException: Type HybridDictionary must implement IMobileObject at Csla.Serialization.Mobile.MobileFormatter.SerializeObject(Object obj) at Csla.Serialization.Mobile.MobileFormatter.SerializeAsDTO(Object graph) at Csla.Serialization.Mobile.MobileFormatter.Serialize(Stream serializationStream, Object graph) at Csla.Core.UndoableBase.CopyState(Int32 parentEditLevel) at Csla.Core.FieldManager.FieldDataManager.Csla.Core.IUndoableObject.CopyState(Int32 parentEditLevel, Boolean parentBindingEdit) at Csla.Core.UndoableBase.CopyState(Int32 parentEditLevel) at ConsoleApp1.Program.Main(String[] args) in D:\Temp\ClassLibrary1\ConsoleApp1\Program.cs:line 13

rockfordlhotka commented 6 years ago

I have a possible fix in this PR - at least your test app now runs 😄 https://github.com/MarimerLLC/csla/pull/899