title: Failed to initialize client proxy: could not connect to vstest.discoveryengine.x86.exe
body: <p>Before, I was able to run the unit tests of a particular project under Visual Studio 2013 just fine. This has recently stopped working <em>without major changes to the project</em>, and unfortunately I do not recall when it did last work, nor what changed since. However, any modifications to the project itself were minimal (one or two new methods), and did not involve <a href="https://stackoverflow.com/q/13533259/590790">any configuration file changes or similar frequently reported issues</a>. I believe rather that a change in Visual Studio (perhaps a recent update), or plug-ins or third party software is causing the following issue.</p>
  
  <p>While loading the project, after one minute the "Tests" output in the Output Window shows:</p>
  
  <blockquote>
    <p>------ Discover test started ------<br>
    Failed to initialize client proxy: could not connect to test process vstest.discoveryengine.x86.exe.<br>
    ========== Discover test finished: 0 found (0:00:59.8853102) ==========</p>
  </blockquote>
  
  <p><a href="https://stackoverflow.com/a/23617438/590790">Similar to a previously reported problem where just debugging stopped working</a>, running Visual Studio as administrator seems to 'resolve' the issue. However this is simply an indication the problem might have got something to do with access rights.</p>
  
  <p>I found <a href="https://connect.microsoft.com/VisualStudio/feedback/details/807771/visual-studio-2013-test-explorer-only-works-if-run-as-administrator" rel="noreferrer">a related Microsoft Connect bug report</a>, which also hints at the problem being caused by a third party application. Apparently <code>vstest.discoveryengine.x86.exe</code> uses named pipes to communicate with <code>devenv.exe</code>. Another application could consume the request, thus resulting in a failed connection for Visual Studio. However, <a href="https://stackoverflow.com/a/258825/590790">verifying which named pipes were in use</a>, I did not find any immediately obvious culprits. I also imagine the connection might fail for other reasons.</p>
  
  <p><a href="http://blogs.msdn.com/b/aseemb/archive/2012/03/02/how-to-enable-ute-logs.aspx" rel="noreferrer">After enabling logging for</a> <code>devenv.exe</code>, <code>vstest.executionengine.exe</code> and <code>vstest.discoveryengine.exe</code> I found the following exceptions related to the discovery engine in the devenv log:</p>
  
  <pre><code>E, 10048, 42, 2014/12/22, 01:47:13.683, 63637924754, devenv.exe, TestRunnerServiceClient: Could not connect to test runner service within the available time 60000. Reason:System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at net.pipe://steven-flip/vstest.discoveryengine/8232 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
  
  Server stack trace: 
     at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper&amp; timeoutHelper)
     at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper&amp; timeoutHelper)
     at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper&amp; timeoutHelper)
     at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
     ...
  </code></pre>
  
  <p>... and later on, a similar exception for <code>vstest.executionengine.exe</code></p>
  
  <pre><code>E, 10048, 40, 2014/12/22, 01:47:15.600, 63642778910, devenv.exe, TestRunnerServiceClient: Could not connect to test runner service within the available time 60000. Reason:System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at net.pipe://steven-flip/vstest.discoveryengine/9884 that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
  
  Server stack trace: 
     at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper&amp; timeoutHelper)
     at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper&amp; timeoutHelper)
     at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper&amp; timeoutHelper)
     at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
  </code></pre>
  
  <p>The execution engine seems to start correctly and waits for incoming requests. The last entry is: <code>TestExecutorService: Created/Started the listening channel. ChannelUri=net.pipe://steven-flip/TestExecutor/4912</code>.</p>
  
  <p>Same goes for the discovery engine of which the last line is: <code>I, 8232, 1, 2014/12/22, 01:46:13.942, 63486587413, vstest.discoveryengine.exe, ServiceMain: Started the service host 8232</code></p>
  
  <p>Did anyone encounter similar problems? How to best tackle this? I do not find constantly running Visual Studio as administrator to be a suitable solution.</p>