Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ContractNamespaceAttribute Class

Specifies the CLR namespace and XML namespace of the data contract.

Namespace: System.Runtime.Serialization
Assembly: System.Runtime.Serialization (in system.runtime.serialization.dll)

'Declaration
<AttributeUsageAttribute(AttributeTargets.Assembly Or AttributeTargets.Module, Inherited:=False, AllowMultiple:=True)> _
Public NotInheritable Class ContractNamespaceAttribute
	Inherits Attribute
'Usage
Dim instance As ContractNamespaceAttribute

/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Module, Inherited=false, AllowMultiple=true) */ 
public final class ContractNamespaceAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Assembly|AttributeTargets.Module, Inherited=false, AllowMultiple=true) 
public final class ContractNamespaceAttribute extends Attribute
Not applicable.

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).

NoteNote:

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 

System.Object
   System.Attribute
    System.Runtime.Serialization.ContractNamespaceAttribute
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.