Problems with deserialization in mono

Does anyone know why the following XML generated by a data serializer in C # works fine on Windows, but not on Linux on Mono?

XML:

<Message i:type="UserMessage" xmlns="http://schemas.datacontract.org/2004/07/NetTunnel"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><type>UserMessage</type>
<nick>Unnamed</nick><services><Service><enabled>true</enabled><port_ranges i:nil="true"/>
<service_name>vent</service_name></Service></services><state>Created</state>
<userid>1</userid></Message>

Error:

Unhandled Exception: System.Runtime.Serialization.SerializationException: Deserializing 
type 'System.Object'. Expecting state 'EndElement'. Encountered state 'Element' with 
name 'enabled' with namespace 'http://schemas.datacontract.org/2004/07/NetTunnel'.

It also gives me an error if there are no services listed (xml tag <services/>). The service variable is of type List<Service>. Is this just the type of Mono can't handle? Would another type be more suitable? Or is it completely different?

+3
source share
3 answers

WCF . protobuf-net. ( ), ( ), . ; , API , " Google". ( , xml, ) .

, , Order ( ):

[DataContract]
public class Foo {
    [DataMember(Order = 1)]
    public int Id {get;set;}

    [DataMember(Order = 2)]
    public string Name {get;set;}
}

( protobuf-net)

, Mono, .NET, CF ..

+1

, , : Mono, .Net, , Mono. , (!) , . , , ..

file it, Mono . : .

: , Mono - List .

+2

Source: https://habr.com/ru/post/1733713/


All Articles