title: Constructor in WCF DataContract not reflected on Client
body: <p>I need to have some data members get some values when I create an instance of the DataContract on the client. This is not happening using constructors. I have searched through different forums and found we have to use [OnDeserializing] and [OnDeserialized] attributes. This is also not working. Can somebody suggest something here. The other alternative is creating constructors in the partial classes at the client side. I want to avoid that.</p>
  
  <p>Please find the code below:</p>
  
  <p>Server-side: Datacontract</p>
  
  <pre><code>[DataContract]
  public class Account
  {
  
      private int mAccountId;
      private string mAccountName;
  
      public Account()
      {
          mAccountId = 5;
          mAccountName = "ABC";
      }
  
      [OnDeserializing]
      public void OnDeserializing(StreamingContext context)
      {
          mAccountId = 5;
          mAccountName = "ABC"; 
      }
  
      [OnDeserialized]
      public void OnDeserialized(StreamingContext context) 
      {
  
      } 
  
      [DataMember]
      public int AccountId
      {
          get
          {
              return mAccountId;
          }
          set
          {
              mAccountId = value;
          }
      }
  
      [DataMember]
      public string AccountName
      {
          get
          {
              return mAccountName;
          }
          set
          {
              mAccountName = value;
          }
      }
  
  
  }
  </code></pre>
  
  <p>Client side - initialization</p>
  
  <pre><code>namespace TestClient
  {
      public partial class _Default : System.Web.UI.Page
      {
          protected void Page_Load(object sender, EventArgs e)
          {
              Account acc = new Account();
  
          }
      }
  }
  </code></pre>