Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/262.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XmlSchema.Read无法正确加载xsd_C#_Xsd - Fatal编程技术网

C# XmlSchema.Read无法正确加载xsd

C# XmlSchema.Read无法正确加载xsd,c#,xsd,C#,Xsd,我尝试使用XmlSchema.Read加载xsd文件。它运行时没有错误,我可以看到它从文件中读取名称空间,但我无法从xsd文件中读取任何其他数据 这是我的密码: public XmlSchema GetXSDFileAsXMLSchema() { FileStream fs = new FileStream(path, FileMode.Open); XmlSchema schema = XmlSchema.Read(fs, new ValidationE

我尝试使用XmlSchema.Read加载xsd文件。它运行时没有错误,我可以看到它从文件中读取名称空间,但我无法从xsd文件中读取任何其他数据

这是我的密码:

public XmlSchema GetXSDFileAsXMLSchema()
    {
        FileStream fs = new FileStream(path, FileMode.Open);
        XmlSchema schema = XmlSchema.Read(fs, new ValidationEventHandler(ValidationCallBack));
        return schema;
    }

    private void ValidationCallBack(object sender, ValidationEventArgs args)
    {
        return; 
    }  

有人知道为什么元素的计数为0吗?

MSDN说,只有在调用Compile()之后,元素才会被填充。在此之前,您可以使用模式的原始元素,如Items。

MSDN说,元素只有在调用Compile()后才能填充。在此之前,您可以使用模式的原始元素,如Items。

此外,他应该使用
块将
FileStream
放入
中。该方法已被弃用。此外,他应该将
FileStream
放入
using
块中。这些方法已被弃用。