title: Getting "Object is read only" error when setting ClientCredentials in WCF
body: <p>I have a proxy object generated by Visual Studio (client side) named ServerClient. I am attempting to set ClientCredentials.UserName.UserName/Password before opening up a new connection using this code:</p>
  
  <pre><code>InstanceContext context = new InstanceContext(this);
  
  m_client = new ServerClient(context);
  m_client.ClientCredentials.UserName.UserName = "Sample";
  </code></pre>
  
  <p>As soon as the code hits the UserName line it fails with an "Object is read-only" error. I know this can happen if the connection is already open or faulted, but at this point I haven't called context.Open() yet. </p>
  
  <p>I have configured the Bindings (which uses netTcpBinding) to use Message as it's security mode, and MessageClientCredentialType is set to UserName.</p>
  
  <p>Any ideas?</p>