DataContractAttribute.Namespace 属性

定义

获取或设置类型的数据协定的命名空间。Gets or sets the namespace for the data contract for the type.

public:
 property System::String ^ Namespace { System::String ^ get(); void set(System::String ^ value); };
public string Namespace { get; set; }
member this.Namespace : string with get, set
Public Property Namespace As String

属性值

String

协定的命名空间。The namespace of the contract.

注解

如果类型返回的数据必须符合特定数据协定,请使用此属性来指定特定的命名空间。Use this property to specify a particular namespace if your type must return data that complies with a specific data contract.

提示

为了成功传送数据,数据协定中的数据名必须与客户端和服务器中的数据名保持一致。For the data to be successfully transmitted, the name of the data in a data contract must be the same in both the client and the server. 默认情况下,Visual Basic 项目将前缀添加到 (名为 "根命名空间" 的每个文件中定义的命名空间,该命名空间按项目) 命名。Visual Basic projects, by default, add a prefix to the namespace defined in each file (called the "root namespace," named after the project). 添加此前缀会造成相同类型的客户端命名空间和服务器命名空间不相同。Adding this prefix causes the client and server namespaces to be different for the same type. 解决方法是将属性设置 Namespace 为 "",或在此属性中显式设置数据协定命名空间。The solution is to set the Namespace property to "", or to explicitly set the data contract namespace in this property.

适用于