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.

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|AttributeTargets.Method|AttributeTargets.Interface, Inherited=false, AllowMultiple=false)] 
public sealed class DataContractFormatAttribute : Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface, Inherited=false, AllowMultiple=false) */ 
public final class DataContractFormatAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Class|AttributeTargets.Method|AttributeTargets.Interface, Inherited=false, AllowMultiple=false) 
public final class DataContractFormatAttribute extends Attribute
Not applicable.

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)]
    double Add(double a, double b);

    [OperationContract, DataContractFormat(Style = OperationFormatStyle.Document)]            
    double Subtract(double a, double b);
}

System.Object
   System.Attribute
    System.ServiceModel.DataContractFormatAttribute

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 CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, 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