gpt4 book ai didi

c# - 调试 MSpec 测试时如何避免 DisconnectedContext 异常?

转载 作者:太空狗 更新时间:2023-10-30 01:33:20 27 4
gpt4 key购买 nike

我在调试 MSpec 测试时遇到了 DisconnectedContext 错误,即使是在包含空测试的新项目中也是如此。该消息表示托管调试助手在

C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\te.processhost.managed.exe

在另一个解决方案中,我在调试时得到一个 FileNotFoundException

C:\USERS\ME\APPDATA\LOCAL\MICROSOFT\VISUALSTUDIO\14.0\EXTENSIONS\WGPFTPGA.WNV\Machine.VSTestAdapter.resources.dll

是Visual Studio突然损坏还是设置问题?我已经尝试重新安装 MSpec 测试适配器。

最佳答案

我今天遇到了同样的错误。我试图将 log4net 添加到我在 VS2015 中的测试项目中。我只是添加了一个 <log4net>我的 app.config 中 <configuration> 下的部分(带有子节点 appender、root、logger...)。然后我得到了错误:

DisconnectedContext occurred

Message: Managed Debugging Assistant 'DisconnectedContext' has detected a problem in 'C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 14.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\te.processhost.managed.exe'.

Additional information: Transition into COM context 0x1301ae0 for this RuntimeCallableWrapper failed with the following error: The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED)). This is typically because the COM context 0x1301ae0 where this RuntimeCallableWrapper was created has been disconnected or it is busy doing something else. Releasing the interfaces from the current COM context (COM context 0x1301970). This may cause corruption or data loss. To avoid this problem, please ensure that all COM contexts/apartments/threads stay alive and are available for context transition, until the application is completely done with the RuntimeCallableWrappers that represents COM components that live inside them.

此外,在调试输出中,有一条关于 ConfigurationErrorsException 的有用消息:

------ Run test started ------
NUnit VS Adapter 2.0.0.0 executing tests is started
Loading tests from C:\....Tests.dll
Exception System.Configuration.ConfigurationErrorsException, Exception thrown executing tests in C:\....\Tests.dll
NUnit VS Adapter 2.0.0.0 executing tests is finished
========== Run test finished: 0 run (0:00:46.9507369) ==========

我意识到你还需要添加一个 <section>申报 <configSections> :

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>

添加这个之后,错误消失了。不确定这是否与您的错误有关,但它可能会有所帮助。

关于c# - 调试 MSpec 测试时如何避免 DisconnectedContext 异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34106992/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com