title: Configure wcf service programmatically
body: <p>I have a remote wcf service, I connect it by WSHttpBinding. If I use the empty service constructor which mean it will take all the configurations from the app.config , everything is ok, (I mean MyService s = new MyService()).
  Now I want to configure the wcf programmatically . it's simple till I arrive to the authentication issue , it was so hard to do that . Here is the app.config which I use , you can see there my security configurations . </p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;bindings&gt;
          &lt;wsHttpBinding&gt;
              &lt;binding name="SecuredEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
                  receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
                  transactionFlow="false" hostNameComparisonMode="StrongWildcard"
                  maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                  messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
                  allowCookies="false"&gt;
                  &lt;readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                      maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
                  &lt;reliableSession ordered="true" inactivityTimeout="00:10:00"
                      enabled="true" /&gt;
                  &lt;security mode="Message"&gt;
                      &lt;transport clientCredentialType="Windows" proxyCredentialType="None"
                          realm="" /&gt;
                      &lt;message clientCredentialType="UserName" negotiateServiceCredential="true"
                          algorithmSuite="Default" /&gt;
                  &lt;/security&gt;
              &lt;/binding&gt;               
          &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
          &lt;endpoint address="http://MyWcfService.svc"
              binding="wsHttpBinding" bindingConfiguration="SecuredEndPoint"
              contract="ServiceReference1.IMyService" name="SecuredEndPoint"&gt;
              &lt;identity&gt;
                  &lt;certificate encodedValue="*******************************************************************" /&gt;
              &lt;/identity&gt;
          &lt;/endpoint&gt;            
      &lt;/client&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>