title: Error Operation not supported with my attributes knowntype
body: <p>I already read this in link <a href="https://stackoverflow.com/questions/9846746/operation-not-supported-in-the-wcf-test-client">Operation not supported in the WCF Test Client</a></p>
  <p>Error while I try running this</p>
  <blockquote>
  <p>the operation is not supported in the WCF GetBatch()</p>
  </blockquote>
  <p>This is my Classes how to fix this</p>
  <pre class="lang-cs prettyprint-override"><code>[KnownType(typeof(Contract))]
  [KnownType(typeof(TotalAmount))]
  [KnownType(typeof(SubjectRole))]
  [KnownType(typeof(ContractData))]
  [KnownType(typeof(MonthlyPayment))]
  [KnownType(typeof(ProlongationAmount))]
  [DataContract]
  public class Batch
  {
      private string batchIdentifierField;
      private Contract contractField;
      [DataMember]
      public string BatchIdentifier
      {
          get { return this.batchIdentifierField;}
          set { this.batchIdentifierField = value;}
      }
  
      [DataMember]
      public Contract Contract
      {
          get { return this.contractField;}
          set { this.contractField = value;}
      }
  }
  
  [DataContract(Name = &quot;Contract&quot;)]
  public partial class Contract
  {
  \\\other fields
    [DataMember]
    public ContractData ContractData{get;set;}
    [DataMember]
    public SubjectRole[] SubjectRole{get;set;}
  \\\other fields
  }
  
  [DataContract(Name = &quot;ContractData&quot;)]
  public partial class ContractData
  {
  \\\other fields
    [DataMember]
    public TotalAmount TotalAmount{get;set;}
  
    [DataMember]
    public MonthlyPayment TotalMonthlyPayment{get;set;}
  
    [DataMember]
    public ProlongationAmount ProlongationAmount{get;set;}
  \\\other fields
  }
  
  [DataContract(Name = &quot;TotalAmount&quot;)]
  public partial class TotalAmount{}
  
  [DataContract(Name = &quot;MonthlyPayment&quot;)]
  public partial class MonthlyPayment{}
  
  [DataContract(Name = &quot;ProlongationAmount&quot;)]
  public partial class ProlongationAmount{}
  </code></pre>
  <p>Interface</p>
  <pre class="lang-cs prettyprint-override"><code>[ServiceContract]
      public interface IBankService
      {
          [OperationContract]
          Batch GetBatch(string DateTime);
  
          [OperationContract]
          string AddBatch(Batch entityBatch);
  
          [OperationContract]
          string AddLocalBatch(string localPath);
  
          [OperationContract]
          string Ping();
      }
  </code></pre>
  <p>And this is Methods which doesn't work</p>
  <pre class="lang-cs prettyprint-override"><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Runtime.Serialization;
  using System.ServiceModel;
  using System.ServiceModel.Web;
  using System.Text;
  using ModelContract;
  using DABatch;
  
  namespace WCF_Service
  {
      // Realization my Methods
  public class BankService : IBankService
  {
      public Batch GetBatch(string datetime)
      {
          try
          {
              DateTime date = DateTime.Parse(datetime); 
              if (datetime.IsEmpty())
                  {
                  Debug.WriteLog(&quot;Field Datetime is Empty&quot;);
                  return new Batch();
              }
  
              using (BatchContext db = new BatchContext())
              {
                  if (db.DBBatches.Any(x =&gt; x.Contract.ContractData.StartDate.Equals(date)))
                  {
                      //.......
                      return ChangedBatch;
                  }
                  else
                  {
                      //Just insert Time and create new object
                      //......
                      return newBatch;
                  }
              }
          }
          catch(Exception ex)
          {
              Debug.WriteLog(ex.Message);
              return new Batch();
          }
      }
  
      public string AddBatch(Batch entityBatch)
      {
          try
          {
              if (entityBatch == null)
              {
                  Debug.WriteLog(&quot;Batch entity is Empty&quot;, new NullReferenceException());
                  return &quot;Error : Batch entity is Empty, nothing to Load&quot;;
              }
  
              using (BatchContext db = new BatchContext())
              {
                  db.DBBatches.Add(entityBatch);
                  return &quot;Add Operation Success!&quot;;
              }
          }
          catch(Exception ex)
          {
              Debug.WriteLog(ex.Message);
              return string.Format($&quot;Error : {ex.Message}&quot;);
          }
      }
  
      public string AddLocalBatch(string localPath)
      {
          try
          {
              if (localPath.IsEmpty())
              {
                  Debug.WriteLog(&quot;Link is Empty&quot;);
                  return &quot;Error : Link is Empty, nothing to Load&quot;;
              }
  
              var entityBatch = XmlReader.Read(localPath);
  
              using (BatchContext db = new BatchContext())
              {
                  db.DBBatches.Add(entityBatch);
                  return &quot;Add Operation Success!&quot;;
              }
          }
          catch (Exception ex)
          {
              Debug.WriteLog(ex.Message);
              return string.Format($&quot;Error : {ex.Message}&quot;);
          }
      }
  
      public string Ping()
      {
          return string.Format($&quot;Service is working. OK! Date : {DateTime.Now.ToLongDateString()} Time: {DateTime.Now.ToLongTimeString()}&quot;);
      }
  }
  </code></pre>
  <p>AddLocalBatch is Working.</p>
  <p>I don't know what to add in this question.</p>
  <p>I tried every method in <a href="https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/data-contract-known-types" rel="nofollow noreferrer">this link</a>.</p>
  <p><a href="https://i.stack.imgur.com/3D1BF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3D1BF.png" alt="WCF is Running" /></a></p>