title: C# Custom Class(server user) in WCF service not working in client(but struct work)(problem)
body: <p>//I have wcf service is hosted by the console application.
  <a href="https://i.stack.imgur.com/C1cYc.png" rel="nofollow noreferrer">console app</a></p>
  <pre><code>  using System.ServiceModel;
   using System.Text;
   using System.Threading.Tasks;
  
     namespace ConsoleApp1
   {
     class Program
     {
      static void Main(string[] args)
      {
          try
          {
              using (var host = new ServiceHost(typeof(ClassLibrary1.wcf_chating)))
              {
  
                  host.Open();
                  Console.WriteLine(&quot;Стартуем!&quot;);
                  Console.ReadLine();
  
              }
          }
          catch (Exception ex)
          {
              
              Console.WriteLine($&quot;Исключение: {ex.Message}&quot;);
              Console.WriteLine($&quot;Исключение: {ex.InnerException}&quot;);
              Console.WriteLine($&quot;Исключение: {ex.TargetSite}&quot;);
              Console.WriteLine($&quot;Исключение: {ex.Source}&quot;);
              Console.WriteLine($&quot;Исключение: {ex.StackTrace}&quot;);
              Console.ReadLine();
          }
      }
  }
  </code></pre>
  <p>}</p>
  <p>//contract hosted in console</p>
  <pre><code>    using System;
      using System.Collections.Generic;
      using System.Linq;
       using System.Runtime.Serialization;
       using System.ServiceModel;
       using System.Text;
       using MySql.Data.MySqlClient;
       namespace ClassLibrary1
      {
  
  [ServiceContract(CallbackContract =typeof(i_call_back))]
  [ServiceKnownType(typeof(ServerUser))]
  public interface Iwcf_chating
  {     
  
      [OperationContract]
      void connect(string name, int ID);
      [OperationContract]
     
      void disconnect(int id);
      [OperationContract(IsOneWay =true)]
      void senmessage(String msg,int id);
      
  }
  public interface i_call_back
  {
      [OperationContract(IsOneWay = true)]
      void mescallback(String msg);   
  }
  [ServiceContract(CallbackContract =typeof(i_call_back2))]
  public interface Idatabase
  {
      [OperationContract]
     void dataconnect();
      
      [OperationContract]
      DataUser Checproverka1(String text1, String  text2);
      [OperationContract]
      DataUser Checproverka2(String text1);
      [OperationContract]
      void insertresults(String text1, String text2, String text3, String text4);
     !!!! [OperationContract](problem metod because return custom class if i only delete this 
       metod i can connect with my client application )
      List&lt;ServerUser&gt; Online_Vivod();
     }
    public interface i_call_back2
    {
      [OperationContract(IsOneWay = true)]       
      void mescallback2(String name);
    }  
   }
  </code></pre>
  <p>//app.config file</p>
  <pre><code> &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;configuration&gt;
   &lt;startup&gt;
   &lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.6.1&quot; /&gt;
   &lt;/startup&gt;
   &lt;system.serviceModel&gt;
   &lt;behaviors&gt;
    &lt;serviceBehaviors&gt;
      &lt;behavior name=&quot;gametime&quot;&gt;
        &lt;serviceMetadata httpGetEnabled=&quot;true&quot;/&gt;      
      &lt;/behavior&gt;
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  &lt;services&gt;
    &lt;service name=&quot;ClassLibrary1.wcf_chating&quot; behaviorConfiguration=&quot;gametime&quot;&gt;       
      &lt;endpoint address=&quot;&quot; binding=&quot;netTcpBinding&quot; contract=&quot;ClassLibrary1.Idatabase&quot;&gt;
      &lt;/endpoint&gt;
      &lt;endpoint address=&quot;&quot; binding=&quot;wsDualHttpBinding&quot; contract=&quot;ClassLibrary1.Iwcf_chating&quot;&gt;
      &lt;/endpoint&gt;
      &lt;endpoint address=&quot;mex&quot; binding=&quot;mexHttpBinding&quot; contract=&quot;IMetadataExchange&quot; /&gt;
      &lt;host&gt;
        &lt;baseAddresses&gt;           
          &lt;add baseAddress=&quot;http://192.168.1.65:8302&quot; /&gt;
          &lt;add baseAddress=&quot;net.tcp://192.168.1.65:8301&quot; /&gt;
        &lt;/baseAddresses&gt;
      &lt;/host&gt;
    &lt;/service&gt;
     &lt;/services&gt;
      &lt;/system.serviceModel&gt;
    &lt;runtime&gt;
    &lt;assemblyBinding xmlns=&quot;urn:schemas-microsoft-com:asm.v1&quot;&gt;
    &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name=&quot;System.Runtime.CompilerServices.Unsafe&quot; 
       publicKeyToken=&quot;b03f5f7f11d50a3a&quot; culture=&quot;neutral&quot; /&gt;
      &lt;bindingRedirect oldVersion=&quot;0.0.0.0-4.0.5.0&quot; newVersion=&quot;4.0.5.0&quot; /&gt;
    &lt;/dependentAssembly&gt;
    &lt;dependentAssembly&gt;
      &lt;assemblyIdentity name=&quot;System.Buffers&quot; publicKeyToken=&quot;cc7b13ffcd2ddd51&quot; 
      culture=&quot;neutral&quot; /&gt;
      &lt;bindingRedirect oldVersion=&quot;0.0.0.0-4.0.3.0&quot; newVersion=&quot;4.0.3.0&quot; /&gt;
    &lt;/dependentAssembly&gt;
   &lt;/assemblyBinding&gt;
    &lt;/runtime&gt;
    &lt;/configuration&gt;
  </code></pre>
  <p>//file have custom class and struct(client see struct but cant see my class)</p>
  <pre><code>      using System;
        using System.Collections.Generic;
        using System.Linq;
         using System.Text;
        using System.Threading.Tasks;
        using System.ServiceModel;
        using System.Runtime.Serialization;
  
      namespace ClassLibrary1
    { 
  [DataContract]
  public class ServerUser
  {
      [DataMember]
      public int ID { get; set; }
      [DataMember]
      public string name { get; set; }
      [DataMember]
      public OperationContext operationContext { get; set; }
  
      public ServerUser(OperationContext operationContext, string name, int Id)
      {
  
  
          this.operationContext = operationContext;
          this.name = name;
          this.ID = Id;
      }
      public ServerUser()
      {
  
      }
  
  }
  [DataContract]
  public struct DataUser
  {
      [DataMember]
      public string msg;
      [DataMember]
      public string name;
      [DataMember]
      public int Id;
      public DataUser(string msg,string name,int Id)
      {
          this.msg = msg;
          this.name = name;
          this.Id = Id;
      }              
     }
      }
  </code></pre>
  <p>//error
  <a href="https://i.stack.imgur.com/METSi.png" rel="nofollow noreferrer">error visual studio Произошла ошибка при загрузке ''http://localhost:8302/$metadata''.
  Отказ при выполнении запроса с состоянием HTTP 400: Bad Request.now allow metod...</a></p>
  <p>settings connect
  <a href="https://i.stack.imgur.com/XP0V6.png" rel="nofollow noreferrer">connect wcf in client settings</a></p>
  <p>//servic interface and struct is auto generated by Service in client i guess but i dont see my class in client auto generate file. Server success compile but cant connect with my client when i return custom class
  //i show you part auto file too</p>
  <pre><code>  namespace WindowsFormsApp12.ChatService {
     using System.Runtime.Serialization;
     using System;   
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCodeAttribute(&quot;System.Runtime.Serialization&quot;, &quot;4.0.0.0&quot;)]
    [System.Runtime.Serialization.DataContractAttribute(Name=&quot;DataUser&quot;, 
     Namespace=&quot;http://schemas.datacontract.org/2004/07/ClassLibrary1&quot;)]
       [System.SerializableAttribute()]
       public partial struct DataUser : System.Runtime.Serialization.IExtensibleDataObject, 
        System.ComponentModel.INotifyPropertyChanged {
      
      [System.NonSerializedAttribute()]
      private System.Runtime.Serialization.ExtensionDataObject extensionDataField;
      
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private int IdField;
      
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private string msgField;
      
      [System.Runtime.Serialization.OptionalFieldAttribute()]
      private string nameField;
      
      public System.Runtime.Serialization.ExtensionDataObject ExtensionData {
          get {
              return this.extensionDataField;
          }
          set {
              this.extensionDataField = value;
          }
      }
      
      [System.Runtime.Serialization.DataMemberAttribute()]
      public int Id {
          get {
              return this.IdField;
          }
          set {
              if ((this.IdField.Equals(value) != true)) {
                  this.IdField = value;
                  this.RaisePropertyChanged(&quot;Id&quot;);
              }
          }
      }
      
      [System.Runtime.Serialization.DataMemberAttribute()]
      public string msg {
          get {
              return this.msgField;
          }
          set {
              if ((object.ReferenceEquals(this.msgField, value) != true)) {
                  this.msgField = value;
                  this.RaisePropertyChanged(&quot;msg&quot;);
              }
          }
      }
      
      [System.Runtime.Serialization.DataMemberAttribute()]
      public string name {
          get {
              return this.nameField;
          }
          set {
              if ((object.ReferenceEquals(this.nameField, value) != true)) {
                  this.nameField = value;
                  this.RaisePropertyChanged(&quot;name&quot;);
              }
          }
      }
      
      public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
      
      void RaisePropertyChanged(string propertyName) {
          System.ComponentModel.PropertyChangedEventHandler propertyChanged = 
         this.PropertyChanged;
          if ((propertyChanged != null)) {
              propertyChanged(this, new 
       System.ComponentModel.PropertyChangedEventArgs(propertyName));
          }
      }
       }
  
      [System.CodeDom.Compiler.GeneratedCodeAttribute(&quot;System.ServiceModel&quot;, &quot;4.0.0.0&quot;)]
      [System.ServiceModel.ServiceContractAttribute(ConfigurationName=&quot;ChatService.Idatabase&quot;, 
        CallbackContract=typeof(WindowsFormsApp12.ChatService.IdatabaseCallback))]
         public interface Idatabase {
  
         [System.ServiceModel.OperationContractAttribute(Action=&quot;http://temp 
         uri.org/Idatabase/dataconnect&quot;, 
                ReplyAction=&quot;http://tempuri.org/Idatabase/dataconnectResponse&quot;)]
      void dataconnect();
      
      [
  </code></pre>
  <p>............</p>