title: MessageSecurityException when trying to access WCF service from WinForms
body: <p>I have a WinForms application that consumes a WCF service hosted on remote server. When I run the application, it runs and loads data, but after 30 seconds or more of the running it shows following <code>MessageSecurityException</code>:</p>
  
  <blockquote>
    <p>Security processor was unable to find a security header in the
    message. This might be because the message is an unsecured fault or
    because there is a binding mismatch between the communicating parties.
    This can occur if the service is configured for security and the
    client is not using security.</p>
  </blockquote>
  
  <p>My Service Config is:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
      &lt;!-- change --&gt;
      &lt;bindings&gt;
        &lt;customBinding&gt;
          &lt;binding name="Wrabind" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:25:00"&gt;
            &lt;textMessageEncoding/&gt;
            &lt;security authenticationMode="SecureConversation" includeTimestamp="true" messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"&gt;
              &lt;localClientSettings maxClockSkew="00:30:00" /&gt;
              &lt;localServiceSettings maxClockSkew="00:30:00" /&gt;
              &lt;secureConversationBootstrap messageSecurityVersion="WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10"&gt;
                &lt;localClientSettings maxClockSkew="00:30:00" /&gt;
                &lt;localServiceSettings maxClockSkew="00:30:00" /&gt;
              &lt;/secureConversationBootstrap&gt;
            &lt;/security&gt;
            &lt;httpTransport maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" allowCookies="true" maxBufferSize="20000000" keepAliveEnabled="false" /&gt;
          &lt;/binding&gt;
        &lt;/customBinding&gt;
      &lt;/bindings&gt;
      &lt;!-- change --&gt;
      &lt;services&gt;
        &lt;service behaviorConfiguration="WServiceCoreService.Service1Behavior" name="WServiceCoreService.Service1"&gt;
          &lt;endpoint address="http://subdomain.domain.com/service1.svc" binding="customBinding" bindingConfiguration="Wrabind" contract="WServiceCoreService.IService1" /&gt;
          &lt;endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /&gt;
        &lt;/service&gt;
      &lt;/services&gt;
      &lt;behaviors&gt;
        &lt;serviceBehaviors&gt;
          &lt;behavior name="WServiceCoreService.Service1Behavior"&gt;
            &lt;serviceThrottling
  maxConcurrentCalls="200"
  maxConcurrentSessions="200"
  maxConcurrentInstances="200" /&gt;
            &lt;!-- To avoid disclosing metadata information, set the value below to false before deployment --&gt;
            &lt;serviceMetadata httpGetEnabled="false" /&gt;
  
            &lt;!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information --&gt;
            &lt;serviceDebug includeExceptionDetailInFaults="true" /&gt;
  
          &lt;/behavior&gt;
        &lt;/serviceBehaviors&gt;
      &lt;/behaviors&gt;
      &lt;serviceHostingEnvironment&gt;
        &lt;baseAddressPrefixFilters&gt;
          &lt;add prefix="http://subdomain.domain.com/" /&gt;
        &lt;/baseAddressPrefixFilters&gt;
      &lt;/serviceHostingEnvironment&gt;
  
  
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>My WinForms Client Config is:</p>
  
  <pre><code>&lt;system.serviceModel&gt;
  
      &lt;bindings&gt;
        &lt;wsHttpBinding&gt;
          &lt;binding name="CustomBinding_IService1"  maxBufferPoolSize="20000000" maxReceivedMessageSize="20000000" allowCookies="true" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:25:00"&gt;
            &lt;readerQuotas maxDepth="32" maxStringContentLength="5242880" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /&gt;
  
          &lt;/binding&gt;
        &lt;/wsHttpBinding&gt;
      &lt;/bindings&gt;
      &lt;client&gt;
        &lt;endpoint address="http://subdomain.domain.com/service1.svc" binding="wsHttpBinding"
          bindingConfiguration="CustomBinding_IService1" contract="WCoreService.IService1"
          name="CustomBinding_IService1"&gt;
          &lt;identity&gt;
            &lt;userPrincipalName value="WIN-489ESBTC0A0\servewranglein_web" /&gt;
          &lt;/identity&gt;
        &lt;/endpoint&gt;
      &lt;/client&gt;
    &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>I am unable to predict what is the error with this configuration. Please help me to solve this as soon as possible.</p>
  
  <p><strong>UPDATE</strong>: I am using .NET 4.0</p>