title: How can I test to see if a net pipe service is listening
body: <p>How can I test programmatically to see if a particular net pipe service is running and listening, so I don't get a "There was no endpoint listening at..." exception?</p>
  
  <p>So for instance if I have this code:</p>
  
  <pre><code>Uri baseAddress = new Uri("http://localhost/something");
  var _ServiceHost = new ServiceHost(typeof(Automation), new Uri[] { baseAddress });
  NetNamedPipeBinding nnpb = new NetNamedPipeBinding();
  _ServiceHost.AddServiceEndpoint(typeof(IAutomation), nnpb, "ImListening");
  _ServiceHost.Open();
  </code></pre>
  
  <p>I want from another application communicate with <code>http://localhost/something/ImListening</code> but before I want to make sure is listening so I don't get an exception, or is the exception the only way to test this?</p>