[英]Unable to XMLSerialize a class generated from xsd.exe which has enum
我已经使用xsd.exe为xsd文件生成了类,这些类引用了其他xsd文件,即使用以下命令进行链接
xsd.exe file1.xsd linkfile.xsd /c
生成类,但是在file1.xsd中,我有一个复杂类型
<xsd:complexType name="Department">
<xsd:annotation>
<xsd:documentation>Uses xlink: attributes to connect locations in the document or at any URL by defining an arc and arc type and role.</xsd:documentation>
</xsd:annotation>
<xsd:attributeGroup ref="xlink:deptLink"/>
<xsd:attribute name="SequenceNumber" type="xsd:integer">
<xsd:annotation>
<xsd:documentation>An integer value used to provide an order to multi-instance sibling elements.</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
xlink:deptLink即deptLink复杂类型位于linkfile.xsd文件中,因此当我使用上述命令生成类时,它会在Department类内创建枚举类型的字段。
所以当我尝试使用生成XML
XmlSerializer serailizer = new XmlSerializer(typeof(MainClass));
我收到错误消息
System.Xml.dll中发生了类型为'System.InvalidOperationException'的未处理异常
附加信息:反映类型'MainClass'的错误。
实际的内部异常非常深,即深入到内部异常的许多层,最后
命名空间“ http://www.w3.org/1999/xlink ”中的全局XML属性“ type”引用了不同的类型deptLink和orgLink。 使用XML属性为属性或类型指定另一个XML名称或名称空间。
我正在使用的xlink.xsd具有两个名为“ type”的-xsd属性
我给了不同的名字,它工作正常
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.