Open ajj7060 opened 7 years ago
The MobileFormatter does use DCS to create the XML that is sent over the network. MobileFormatter pulls all the data out of the business object graph into a very simple array of values, and then DCS is used to write that array of values into a byte stream.
What you are seeing is the result of some value in your graph being of a type that DCS can't serialize into XML - so something that isn't a primitive type is a property of your graph.
Hi @rockfordlhotka. That's what I don't understand; the message is complaining about a type (Library.ReadOnlyObject) which inherits ReadOnlyBase
I believe that Enums could be the culprit here.
Read more here about the DCS and Enum: https://msdn.microsoft.com/en-us/library/aa347875(v=vs.110).aspx
@jonnybee But I thought the mobileformatter handled the enums itself. https://github.com/MarimerLLC/cslaforum/issues/284#issuecomment-266848073
Looking at the code, it seems like mobileformatter converts everything to a SerializationInfo (and from Rocky's comment, I would think enums become ints) and that's what goes to the DCS.
I could be misremembering @ajj7060 - I thought we did some special handling for enum
, but maybe not?
@rockfordlhotka I believe it does; I have a sample app where I've been trying to replicate the issue (unsuccessfully so far) and I added a property which is an Enum, and it seems to work fine.
Ok, I think I figured this out. Library.ReadOnlyObject
implements an interface Library.IReadOnlyObject
. We have a ROLB, Library.ReadOnlyObjectList<ReadOnlyObjectList, IReadOnlyObject>
We also have another class, Library.ReadOnlyObject2
which has a MobileList<Library.IReadOnlyObject>
.
It compile and ran, giving the above exception, which was misleading. The issue seemed to be that Library.IReadOnlyObject
didn't for implementers to also implement Csla.Serialization.Mobile.IMobileObject
. Once I made our interface require the IMobileObject interface, everything magically started working.
I think the signals got crossed because at runtime Csla is looking at the type information of the objects actually contained in the list (which is always the Library.ReadOnlyObject
) but the list itself didn't technically require objects to be of IMobileObject.
@rockfordlhotka I actually have a working repo project now, if interested. The issue is specifically the MobileList<T>
if you use an interface for T
which does not force T
to be Csla.Serialization.Mobile.IMobileObject
.
Here's the repo: https://github.com/ajj7060/MobileListInterface
I'm not sure if this is considered an edge case or not; the reason for a list of interfaces vs concreate classes is for unit testing. The actual implementation is very difficult to work with when trying to configure it for a test otherwise.
It would be nice to have another more clear exception thrown in this case. I'd be happy to take a crack at implementing the logic if its agreed that the framework should catch this. My biased opinion is that it should as it took me quiet a while to track down the actual issue :-) I was thinking either during the serialization process or perhaps in RegisterProperty, assuming MobileList and managed properties are always expected for something that will cross the data portal.
We're working on porting our business library to Xamarin for our mobile app support (in addition to supporting our main WinForms application) and I'm hitting an issue with serialization which I'm not sure how to solve.
My understanding is that Csla will automatically use the MobileFormatter on Xamarin (including UWP), and we're using HttpProxy. On the server side it seems that serializing the response to one of our command objects is failing.
This is the exception:
The exception seems to suggest DataContractSerializer is involved, but I thought that the HttpPortalController (which I'm using as the remote host) should always use the MobileFormatter.
Some calls do succeed though, so I don't think its a general problem, but something with the object graph which the command object is returning.
First, any idea why I'm getting this error? Second, why is the DCS involved at all? We do have BinaryFormatter set as the HttpPortalController is hosted in an Asp.Net site which also currently hosts a .Net remoting portal as well.