Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
POCO Support

POCO Support

This sample demonstrates the serialization support for unmarked types; that is, types to which serialization attributes have not been applied, sometimes referred to as Plain Old CLR Object (POCO) types. The DataContractSerializer infers a data contract for all public unmarked types that have a default constructor. Data contracts allow you to pass structured data to and from services. For more information about unmarked types, see Serializable Types.

This sample is based on the Getting Started Sample, but uses complex numbers instead of primitive numeric types. It is also similar to the Basic Data Contract sample, except that the DataContractAttribute and DataMemberAttribute attributes are not used.

The service is hosted by Internet Information Services (IIS) and the client is a console application (.exe).

Cc681329.note(en-us,VS.100).gifNote:
The setup procedure and build instructions for this sample are located at the end of this topic.

The ComplexNumber class is used in the ServiceContract. The ComplexNumber type does not have the DataContractAttribute and DataMemberAttribute attributes, as shown in the following sample code. By default, all public properties and fields are serialized.

public class ComplexNumber
{
    public double Real;
    public double Imaginary;
    public ComplexNumber()
    {
        Real = double.MinValue;
        Imaginary = double.MinValue;
    }
    public ComplexNumber(double real, double imaginary)
    {
        this.Real = real;
        this.Imaginary = imaginary;
    }
}

To set up, build, and run the sample

  1. Ensure that you have performed the One-Time Setup Procedure for the Windows Communication Foundation Samples.

  2. To build the C# or Visual Basic .NET edition of the solution, follow the instructions in Building the Windows Communication Foundation Samples.

  3. To run the sample in a single- or cross-machine configuration, follow the instructions in Running the Windows Communication Foundation Samples.

Cc681329.Important(en-us,VS.100).gif Note:
The samples may already be installed on your machine. Check for the following (default) directory before continuing.

<InstallDrive>:\WF_WCF_Samples

If this directory does not exist, go to Windows Communication Foundation (WCF) and Windows Workflow Foundation (WF) Samples for .NET Framework 4 to download all Windows Communication Foundation (WCF) and WF samples. This sample is located in the following directory.

<InstallDrive>:\WF_WCF_Samples\WCF\Basic\Contract\Data\POCO

See Also

Community Additions

ADD
Show:
© 2015 Microsoft