任何人都知道为什么 C# 中的数据合同序列化程序生成的以下 XML 在 Windows 中可以正常工作,但在 Mono 上的 Linux 下却不行?
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>
错误:
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'.
如果没有列出服务(xml 标签<services/>
),它也会给我一个错误。services 变量的类型为List<Service>
。这只是 Mono 无法处理的类型吗?其他类型会更合适吗?还是完全是别的东西?