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)

[AttributeUsageAttribute(AttributeTargets::Assembly|AttributeTargets::Module, Inherited = false, 
	AllowMultiple = true)]
public ref class ContractNamespaceAttribute sealed : public Attribute

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.

No code example is currently available or this language may not be supported.

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

.NET Framework

Supported in: 3.5, 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft