4

I get a DisconnectedContext error when debugging MSpec tests, even in a new project with an empty test. The message says that the Managed Debug Assistant found a problem in

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

In another solution I get a FileNotFoundException when debugging.

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

Is Visual Studio suddenly damaged or is it a settings problem? I already tried reinstalling the MSpec test adapter.

Anthony Mastrean
  • 21,850
  • 21
  • 110
  • 188
Pad
  • 47
  • 1
  • 6

2 Answers2

2

I got the same error today. I was trying to add log4net to my Tests project in VS2015. I simply added a <log4net> section in my app.config under <configuration> (with subnodes appender, root, logger...). Then I got the error:

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.

Also, in the Debug output, there was a useful message about a 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) ==========

I realized you also need to add a <section> declaration in <configSections>:

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

After adding this, the error went away. Not sure if this relates to your error, but it might help.

Community
  • 1
  • 1
Thierry_S
  • 1,526
  • 16
  • 25
1

This happened to me also. My problem what that I got an uncaugt exception when trying to issue a sql call (some trivial sql problem). This indicates to me that for some strange reason, if you have an uncaugt exception that bubbles up above the test method itself, you may get this. Do a try {everything you are trying to the in the test} catch (Exception e) {Console.WriteLine(e)}

And have a breakpoint on the Console.. Line.

This fixed my problem.

Thomas N
  • 418
  • 1
  • 7
  • 14