Call BeginSave on a Root BusinessListBase

Call BeginSave on a Root BusinessListBase

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


Andrew posted on Thursday, December 13, 2012

Hi,

I just created a BusinessListBase object on monodevelop project which is not a child of any other BusinessBase.

When I tried to call BeginSave on BusinessListBase's instance, an error said " Element is an invalid node type".

when I debug into Csla.ios, I found issue happened at BeginUpdate in LocalProxy in DataPortalClient.

 

public void BeginUpdate(object obj, object userState)

    {

      var handler = new CompletedHandler(OnUpdateCompleted);

      _userState = userState;

      var cloneable = obj as ICloneable;

      if (cloneable != null)

        obj = cloneable.Clone();

 

go deeper,  it happened at CslaXmlBinaryReader in Mobile ,

public class CslaXmlBinaryReader : ICslaReader

{

/// <summary>

/// Read the data from a stream and produce list of <see cref="SerializationInfo"/> objects

/// </summary>

/// <param name="serializationStream">Stream to read the data from</param>

/// <returns>List of SerializationInfo objects</returns>

public List<SerializationInfo> Read(Stream serializationStream)

    {

      List<SerializationInfo> returnValue = null;

      try

      {

        using (var xmlReader = XmlDictionaryReader.CreateBinaryReader(serializationStream, XmlDictionaryReaderQuotas.Max))

        {

 

 

I have attached my classes as zip.

 

Thanks in advance for any help.

 

RockfordLhotka replied on Friday, December 14, 2012

Before you spend much more time (any more time really) you should understand that CSLA .NET only runs in the iOS simulator, not in real iOS. This is because of legal limits from Apple on what monotouch can do in terms of handling some C# features. Sadly CSLA makes heavy use of interfaces that return a generic type, specifically in a way that Apple blocks on real iOS.

So while CSLA .NET works great on iOS in the simulator, it won't work on real devices. Very sad...

Andrew replied on Sunday, December 16, 2012

Thank you very much for your replying.

I had ever faced the Generic problem in using CSLA,  which is as following.

//public static readonly Csla.PropertyInfo<T> ValueProperty = RegisterProperty<T>(c => c.Value);

 

 

 

public static readonly Csla.PropertyInfo<T> ValueProperty = RegisterProperty<T>(new Csla.PropertyInfo<T>("Value"));

 

 

 

 

The commented out line did work on iOS simulator but not on real iOS device. I had to use the code under the commentted-out code instead which worked on both iOS simulator and iOS device.

but the issue I asked might be different, because the problem happened when I tried to run application on iOS Simulator as well.

Currentlty, I tried to avoid this problem by call BeginSave of Business Base one by one instead of  calling BeginSave on Business List Base.

Kind regards,

Andrew

 

 

RockfordLhotka replied on Monday, December 17, 2012

The exception you mention in your original post is a serialization exception.

Because of the issues with generics in iOS we mostly stopped testing or enhancing the iOS codebase. It is very possible that some of the serialization code in MobileFormatter doesn't work for some reason. Or our custom XmlWriter. It is also possible (but I think less likely) that there is a bug with the monotouch DataContractSerializer implementation.

It is possible to configure MobileFormatter to use the Microsoft (monotouch) XmlWriter and XmlReader types. They create much larger XML data streams, but might not have the same issue with iOS.

Copyright (c) Marimer LLC