Pure Mpi.NET

Because Pure Mpi.NET is built on WCF, custom types will need to specify a datacontract using the DataContractSerializer in the System.Runtime.Serialization namespace.   The following example illustrates how to declaratively specify the contract.  Unlike the [Serializable] attribute, the data contract is an opt-in, rather than an opt-out, specification.

    [DataContract]

    public class CustomClass

    {

        [DataMember]

        public int x;

        [DataMember]

        public string y;

    }


 In addition, for security reasons, custom and non-standard types also need to be added to the known types list.  This can be specified in the app.config.  The following example shows how to add the above custom type and an Int32[].


  <system.runtime.serialization>

    <dataContractSerializer>

      <declaredTypes>

        <add type="Mpi.Message, Mpi">

          <knownType type="CustomType.CustomClass, CustomType" />

          <knownType type="System.Int32[], mscorlib" />

        </add>

      </declaredTypes>

    </dataContractSerializer>

  </system.runtime.serialization>