This documentation is archived and is not being maintained.

DataContractFormatAttribute Class

Instructs the Windows Communication Foundation (WCF) infrastructure to use the DataContractSerializer.

Namespace:  System.ServiceModel
Assembly:  System.ServiceModel (in System.ServiceModel.dll)

<AttributeUsageAttribute(AttributeTargets.Class Or AttributeTargets.Method Or AttributeTargets.Interface, Inherited := False,  _
	AllowMultiple := False)> _
Public NotInheritable Class DataContractFormatAttribute _
	Inherits Attribute
Dim instance As DataContractFormatAttribute

This attribute is similar to the XmlSerializerFormatAttribute attribute. Both attributes can be applied to either a method or a class.

A method can have either of the two attributes applied, but not both. Any operation that has neither applied will use the attribute applied to the containing class. If the containing class does not have either attribute applied, the DataContractSerializer is used.

Applying the attribute also causes a DataContractSerializerOperationBehavior to be created at run time. The behavior allows customization at run time of the serializer behavior.

The following example applies the DataContractFormatAttribute and sets the Style property to Rpc. The RPC style is described in the Web Service Description Language specification (WSDL).

<ServiceContract(), DataContractFormat(Style := OperationFormatStyle.Rpc)>  _
Interface ICalculator
    <OperationContract(), DataContractFormat(Style := OperationFormatStyle.Rpc)>  _
    Function Add(ByVal a As Double, ByVal b As Double) As Double 

    <OperationContract(), DataContractFormat(Style := OperationFormatStyle.Document)>  _
    Function Subtract(ByVal a As Double, ByVal b As Double) As Double  
End Interface


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