我使用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 complextype位于linkfile.xsd文件中,因此当我使用上面提到的命令创建类时,它会在Department类中创建一个类型为enum的字段。
所以当我尝试使用
生成xml时XmlSerializer serailizer = new XmlSerializer(typeof(MainClass));
我收到错误
未处理的类型&#39; System.InvalidOperationException&#39;发生在System.Xml.dll
中其他信息:反映类型&#39; MainClass&#39;。
时出现错误答案 0 :(得分:0)
实际的内部异常非常深,即内部异常的多层,最后是
命名空间“http://www.w3.org/1999/xlink”的全局XML属性“type”引用了不同类型的deptLink和orgLink。使用XML属性为一个或多个属性指定另一个XML名称或命名空间。
我使用的xlink.xsd有两个名为“type”的-xsd属性
我给出了不同的名字,它运作良好