title: Win32Exception @ ServiceHost.Open() for WCF service
body: <p>I am working on writing BDD specifications for a broad set of WCF service infrastructure I am writing. I have noticed that each specification I write that involves a call to ServiceHost.Open(), that line takes a good 2 - 6 seconds to execute (the time keeps growing as I add more and more specs). I noticed that when this method is called, a Win32Exception is thrown:</p>
  
  <pre><code>Win32Exception occurred
  Message: The specified domain either does not exist or could not be contacted.
  Stack Trace: at System.ServiceModel.UpnEndpointIdentity.GetUpnFromDownlevelName(String downlevelName)
  NativeErrorCode: 1355
  ErrorCode: -2147467259
  </code></pre>
  
  <p>The ServiceModel configuration is as follows: </p>
  
  <pre><code>&lt;system.serviceModel&gt;
    &lt;services&gt;
      &lt;service name="TestServices.Calculator" behaviorConfiguration="default"&gt;
        &lt;endpoint
          name="calculator"
          address=""
          binding="wsHttpBinding"
          contract="TestServiceContracts.ICalculator" /&gt;
        &lt;endpoint
          address="mex"
          binding="mexHttpBinding"
          contract="IMetadataExchange" /&gt;
        &lt;host&gt;
          &lt;baseAddresses&gt;
            &lt;add baseAddress="http://localhost/calculator" /&gt;
          &lt;/baseAddresses&gt;
        &lt;/host&gt;
      &lt;/service&gt;
    &lt;/services&gt;
  
    &lt;behaviors&gt;
      &lt;serviceBehaviors&gt;
        &lt;behavior name="default" &gt;
          &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;/behavior&gt;
      &lt;/serviceBehaviors&gt;
    &lt;/behaviors&gt;
  &lt;/system.serviceModel&gt;
  </code></pre>
  
  <p>Note: I have configured Http.sys and added <a href="http://+:80/calculator/" rel="nofollow noreferrer">http://+:80/calculator/</a> as an http namespace exclusion, so that is not part of the problem. </p>
  
  <p>This error is most severe on a Windows 7 Ultimate system. On a Vista Ultimate system, it does not seem to cause as much of a performance hit, however ServiceHost.Open() is the vast bulk of the time spent in execution. I don't understand why it is an issue at all when the URL's are localhost...I would expect the loopback interface to be the fastest of all.</p>