Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/24.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# 我可以在XmlSchemaSet.Add()方法的Uri参数中指定本地文件位置吗?_C#_.net_Xml_Schema - Fatal编程技术网

C# 我可以在XmlSchemaSet.Add()方法的Uri参数中指定本地文件位置吗?

C# 我可以在XmlSchemaSet.Add()方法的Uri参数中指定本地文件位置吗?,c#,.net,xml,schema,C#,.net,Xml,Schema,XmlSchemaSet.Add()方法采用Uri和目标命名空间,但当我尝试传入本地文件位置时,它会产生错误 _schemaUri = @"L:\schemaDoc.xsd"; XmlSchemaSet schemas = new XmlSchemaSet(); schemas.Add(_schemaUri, _targetNamespace); 错误: NotSupportedException was caught The URI prefix is not recognized. 对

XmlSchemaSet.Add()
方法采用
Uri
和目标命名空间,但当我尝试传入本地文件位置时,它会产生错误

_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_schemaUri, _targetNamespace);
错误:

NotSupportedException was caught

The URI prefix is not recognized.

对。您混淆了添加方法的参数。第一个参数是目标名称空间,第二个参数是URI。因此,您的代码应该如下所示:

_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_targetNamespace, _schemaUri);
有关更多详细信息,请参阅文档:


是的。您混淆了添加方法的参数。第一个参数是目标名称空间,第二个参数是URI。因此,您的代码应该如下所示:

_schemaUri = @"L:\schemaDoc.xsd";
XmlSchemaSet schemas = new XmlSchemaSet();
schemas.Add(_targetNamespace, _schemaUri);
有关更多详细信息,请参阅文档:


根据MSDN文档,schemaUri和targetNamespace参数的顺序与此相反

来自MSDN:
XmlSchemaSet.Add方法(字符串,字符串)
在指定给XmlSchemaSet的URL处添加XML架构定义语言(XSD)架构

Namespace:  System.Xml.Schema
Assembly:  System.Xml (in System.Xml.dll)

public XmlSchema Add(
    string targetNamespace,
    string schemaUri
)
参数

targetNamespace
Type: System.String
The schema targetNamespace property, or null to use the targetNamespace specified in the schema.

schemaUri
Type: System.String
The URL that specifies the schema to load.  

根据MSDN文档,schemaUri和targetNamespace参数的顺序与此相反

来自MSDN:
XmlSchemaSet.Add方法(字符串,字符串)
在指定给XmlSchemaSet的URL处添加XML架构定义语言(XSD)架构

Namespace:  System.Xml.Schema
Assembly:  System.Xml (in System.Xml.dll)

public XmlSchema Add(
    string targetNamespace,
    string schemaUri
)
参数

targetNamespace
Type: System.String
The schema targetNamespace property, or null to use the targetNamespace specified in the schema.

schemaUri
Type: System.String
The URL that specifies the schema to load.