【问题标题】:Failed to initialize client proxy: could not connect to vstest.discoveryengine.x86.exe初始化客户端代理失败:无法连接到 vstest.discoveryengine.x86.exe
【发布时间】:2015-02-20 02:06:04
【问题描述】:

之前,我能够在 Visual Studio 2013 下运行特定项目的单元测试就好了。这最近停止工作没有对项目进行重大更改,不幸的是我不记得它最后一次工作是什么时候,也不记得从那以后发生了什么变化。但是,对项目本身的任何修改都是最小的(一两个新方法),并且不涉及any configuration file changes or similar frequently reported issues。我认为 Visual Studio 的更改(可能是最近的更新)、插件或第三方软件会导致以下问题。

加载项目时,一分钟后输出窗口中的“测试”输出显示:

------ 发现测试开始------
初始化客户端代理失败:无法连接到测试进程 vstest.discoveryengine.x86.exe。
========== 发现测试已完成:找到 0 个 (0:00:59.8853102) ==========

Similar to a previously reported problem where just debugging stopped working,以管理员身份运行 Visual Studio 似乎“解决”了这个问题。然而,这只是表明问题可能与访问权限有关。

我找到了a related Microsoft Connect bug report,这也暗示问题是由第三方应用程序引起的。显然vstest.discoveryengine.x86.exe 使用命名管道与devenv.exe 通信。另一个应用程序可能会使用该请求,从而导致 Visual Studio 连接失败。但是,verifying which named pipes were in use,我没有发现任何明显的罪魁祸首。我还认为连接可能由于其他原因而失败。

After enabling logging fordevenv.exevstest.executionengine.exevstest.discoveryengine.exe我在devenv日志中发现了以下与发现引擎相关的异常:

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& timeoutHelper)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   ...

... 以及稍后,vstest.executionengine.exe 的类似例外

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& timeoutHelper)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)

执行引擎似乎正确启动并等待传入​​请求。最后一个条目是:TestExecutorService: Created/Started the listening channel. ChannelUri=net.pipe://steven-flip/TestExecutor/4912

发现引擎也是如此,最后一行是:I, 8232, 1, 2014/12/22, 01:46:13.942, 63486587413, vstest.discoveryengine.exe, ServiceMain: Started the service host 8232

有没有人遇到过类似的问题?如何最好地解决这个问题?我不认为以管理员身份持续运行 Visual Studio 是一个合适的解决方案。

【问题讨论】:

  • 您能找到合适的解决方案吗?我遇到了同样的问题。 (就我而言,我使用的是命令行工具 vstest.console.exe,并且我已经以管理员身份运行它)
  • @Turbo Nope,但尚未尝试新设置(Windows 10,新 VS)。
  • @Turbo,你解决过这个问题吗?我现在被屏蔽了。
  • 当我的 vstest 项目已经在运行时,我突然遇到了这个问题。我删除了测试项目并重新添加它,但是 SLN 文件不让我,所以我删除并重新制作了 SLN 文件,重新添加了项目,一切都很好。奇怪...
  • 这仍然在 Visual Studio 2017 中随机发生,没有任何提示说明为什么会发生。

标签: visual-studio mstest


【解决方案1】:

我的问题是我在我的机器上创建了一个新用户,并且 UWP 测试应用程序仍然安装在另一个用户上。这是不允许的(y tho),我不得不卸载它。

要发现应用程序是否已安装,请以管理员身份运行 PowerShell,然后执行以下命令:

Get-AppPackage *YourTestAppNameHere* -AllUsers

如果有结果,则表示应用已安装。然后你可以用这个命令卸载它:

Get-AppPackage *YourTestAppNameHere* -AllUsers | Remove-AppPackage -AllUsers

再次运行第一个命令以验证它是否已正确卸载。

【讨论】:

    【解决方案2】:

    如果此错误发生在之前没有关闭 Visual Studio 或 SLN 的情况下工作的编码会话期间,请查看是否可以从 SLN 中删除测试项目,然后重新添加它。

    如果您不能(或至少没有解决方法),请考虑删除您的 SLN 文件并重新制作它。我就是这样被解封的。没有其他工作,但是 TBH 我懒得去寻找 net.pipe,因为我认为这是一个棘手的自动化问题,并且没有兴趣追求这条路线。

    【讨论】:

      【解决方案3】:

      确保您的 windows 设置已设置为开发人员 - 更改为此设置时将自动安装开发人员包,然后 UWP C# unittest 将运行,否则将给出与您描述的类似的错误

      【讨论】:

        【解决方案4】:

        我在 VS 2015 和 VS 2017 下遇到了同样的问题。在检查了几种方法(禁用 WAS、重新安装 VS 2015、启动 SubInACL 工具、在安全模式下启动 VS 2015 ......)后,我发现:

        • 以管理员身份运行 VS 2015 解决了问题,我的测试资源管理器再次显示测试!不过,我认为这只是一种解决方法,而不是最终解决方案。
        • 所以,经过一番谷歌搜索,我找到了另一个解决方案,其中包括将当前用户的写入/修改权限添加到文件夹“%ProgramData%\Package Cache”。在此link 中查看更多详细信息。现在,在我的用户帐户下启动 VS 2015 时,测试资源管理器会快速发现我的所有测试并且错误消息消失了。

        【讨论】:

          【解决方案5】:

          我在 Windows 10 上使用 Visual Studio 2015 时遇到了同样的问题。经过大量调试后,发现问题出在另一个程序中:

          单独的 vstest 可执行文件使用 WCF 通过命名管道(net.pipe 协议,带有端点 URL,例如 net.pipe://machinename/vstest.discoveryengine/12345)与主引擎(在 Visual Studio 或 VSTest 控制台中运行)进行通信。事实证明,每当在特权帐户下运行的应用程序侦听作为另一个 URL 前缀的 net.pipe URL 时,没有其他非特权帐户可以侦听更长的 URL(只有在以管理员身份运行时才可以)。

          而且,事实证明,有各种以管理员身份运行的应用程序或本地系统侦听net.pipe://localhost/。在这种情况下,在非特权用户下运行的任何 WCF 应用程序(包括 VSTest 进程)都不能在命名管道上运行服务器。你可以try creating a minimal WCF example running on netpipes。即使是那个简单的例子,也只有在以管理员身份运行时才能在我的机器上运行(否则,“在 net.pipe://... 没有端点监听”)。

          我使用 Sysinternals Process Explorer、Ctrl+F 并搜索“net.pipe”以找到打开了 netpipes 的进程。在我的例子中,是 Razer 的“RzWizardService”保持一个 WCF 服务器,其端点直接位于“net.pipe://localhost/”下,作为本地系统服务运行。当我停止服务时,一切都开始正常了。

          【讨论】:

          • 为我工作。不得不关闭大多数使用命名管道的应用程序,这需要一些时间,但是 VS 能够开始调试,并且在我放置在代码中的断点处停止。
          • 在我的情况下,是 iStat Server 导致了问题。必须以管理员身份运行 Process Explorer 才能看到它。感谢您的解决方案。
          【解决方案6】:

          我最近遇到了同样的问题。就像你说的,这可能是来自另一个第 3 方图书馆的一些干扰。 就我而言,我尝试卸载 VS-plugin Emmet。这个对我有用。重新启动后,重新发现测试。

          【讨论】:

            猜你喜欢
            • 1970-01-01
            • 2019-05-05
            • 2018-04-23
            • 1970-01-01
            • 1970-01-01
            • 2021-08-07
            • 1970-01-01
            • 2018-04-25
            • 1970-01-01
            相关资源
            最近更新 更多