Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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 sealed class ContractNamespaceAttribute : Attribute
/** @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]
        internal string FirstName;
        [DataMember]
        internal string LastName;
    }
}

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
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft