ContractNamespaceAttribute Class
Specifies the CLR namespace and XML namespace of the data contract.
Assembly: System.Runtime.Serialization (in System.Runtime.Serialization.dll)
Apply the ContractNamespaceAttribute attribute to an assembly that contains types to which the DataContractAttribute has been applied. The ContractNamespaceAttribute enables you to set a namespace that is different than the one generated when the type is serialized. For more information about how names are generated, see Data Contract Names.
If you are using a type to conform to an existing data contract, you must match the namespace of the existing contract by using the ContractNamespaceAttribute (or the Namespace property of the DataContractAttribute class).
Note: |
|---|
In any code, you can use the word ContractNamespace instead of the longer ContractNamespaceAttribute. |
The following example shows the ContractNamespaceAttribute applied to an assembly.
<assembly: ContractNamespaceAttribute("http://www.cohowinery.com/employees", _ ClrNamespace := "Microsoft.Contracts.Examples")> Namespace Microsoft.Contracts.Examples <DataContract()> _ Public Class Person <DataMember()> _ Friend FirstName As String <DataMember()> _ Friend LastName As String End Class End Namespace
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: