vstest icon indicating copy to clipboard operation
vstest copied to clipboard

The provided manager was not found in any slot.

Open nohwnd opened this issue 1 year ago • 46 comments

I'm having a similar issue, and the build fails with the following trace running in Azure Devops hosted agents:

##[error]DiscoveryMessage : System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)

The issue started when moving from 17.5 to 17.6 two days ago.

Originally posted by @jeromelaban in https://github.com/microsoft/vstest/issues/4467#issuecomment-1553272768

Update: To clarify this issue for future implementation of a fix. When testhost crashes in initialization, we don't communicate back that initialization did not happen and try to continue to the next step, which again does initialization and fails again. This will trigger cleanup 2 times via CompletedRun event, which cleans slots and pushes next work to be executed. First the cleanup will succeed, but the second one will fail. This also highlights that there is a disconnect between the work being done, and when we think the work already completed.

nohwnd avatar May 22 '23 10:05 nohwnd

@jeromelaban Could you please tell me more about how you run your tests (e.g. dotnet test, vstest.console, vstest task, classical / yaml pipeline)?

And what is in your solution, are you multi targetting? Are you running in parallel?

nohwnd avatar May 22 '23 10:05 nohwnd

I am experiencing the same problem, but I am not using Azure Devops, but I also switched to VS version 17.6.0, so it is related to new VS version

PeterHevesi avatar May 23 '23 13:05 PeterHevesi

@PeterHevesi do you have some more details on how to repro this please?

nohwnd avatar May 23 '23 13:05 nohwnd

Sorry, no I don't and I would explore it further to tell you, but I don't have time, I am very busy now, so I am rather downgrading to VS 17.5

PeterHevesi avatar May 23 '23 13:05 PeterHevesi

Totally understandable. Thanks for getting back to me.

nohwnd avatar May 23 '23 14:05 nohwnd

@jeromelaban Could you please tell me more about how you run your tests (e.g. dotnet test, vstest.console, vstest task, classical / yaml pipeline)? And what is in your solution, are you multi targetting? Are you running in parallel?

Thanks for taking a look into this. This is our CI step, and we're using net7.0 and net8.0 binaries.

Here's a larger build log, if that can help.

jeromelaban avatar May 23 '23 15:05 jeromelaban

Okay, thanks, looks like it is in fact related to https://github.com/microsoft/vstest/issues/4467 and a workaround for you would be to provide dll filter that is specific to your test project naming pattern. It seems that most your projects are named Tests..dll something, that should restrict your pattern better than using test.dll:

So I would try replacing this line, with bin/**/*Tests*.dll, and keeping the rest of the exclude rules in place for now to see if it helped.

https://github.com/unoplatform/uno/blob/master/build/ci/.azure-devops-unit-tests.yml#L77

nohwnd avatar May 24 '23 09:05 nohwnd

@nohwnd , Hi, so now I have some more time, so I will tell you my setup: I was using latest Visual Studio 17.6.1 with latest NUnit 3.13.3, NUnit3TestAdapter 4.4.2 and latest Microsoft Playwright 1.33.0 I have latest Microsoft.NET.Test.Sdk 17.6.0 and latest Microsoft.TestPlatform.TestHost 17.6.0 I am using .NET 7 and C# 11 (But because I already downgraded to 17.5.5, and won't upgrade until this will fixed, I can't try to reproduce it again) (But please ask for any other info that may help you)

And so, are you working on fixing this? How it is going? When do you expect it to be fixed?

PeterHevesi avatar May 25 '23 11:05 PeterHevesi

@nohwnd will give a more detailed explanation but the fix is already merged (see https://github.com/microsoft/vstest/pull/4474) and we are working on rolling it out to NuGet, VS and .NET.

Evangelink avatar May 25 '23 12:05 Evangelink

@PeterHevesi I still have not been able to repro this, the related Fix that Amaury mentions might help to fix this. But until I came up with a repro I can't comment on what exactly is going on. Once we have a fix we will roll it out to nuget, and insert into dotnet sdk and VS, as we will be doing with 17.6.1 that has fix fir #4474

nohwnd avatar May 25 '23 14:05 nohwnd

@jeromelaban looking at your build log (reposted below in case the build gets removed). There are several errors that prevent testhost from starting/running. The error The provided manager was not found in any slot. is a consequence of testhost exiting early, I am not yet sure why we cannot find the manager in the slot, but solving this won't solve your issues. Your testhosts will still crash.

I see two types of errors:

Testhost process for source(s) 'D:\a\1\s\src\Build\Tests\bin\Release_AnyCPU\net7.0\Uno.Analyzers.Tests.dll' exited with error: Error: An assembly specified in the application dependencies manifest (Uno.Analyzers.Tests.deps.json) was not found: package: 'DiffPlex', version: '1.5.0' path: 'lib/netstandard1.0/DiffPlex.dll'

There is a dependency in manifest that is not found so the process cannot start.

And

Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'. Failed to run as a self-contained app.

  • The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  • If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.

I can repro with running just in command line.

dotnet test src\Build\Tests\bin\Release_AnyCPU\net7.0\Uno.Analyzers.Tests.dll.

##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests.ViewLibrary\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: Error:
  An assembly specified in the application dependencies manifest (Uno.UI.Tests.ViewLibrary.deps.json) was not found:
    package: 'Microsoft.Extensions.Configuration', version: '5.0.0'
    path: 'lib/netstandard2.0/Microsoft.Extensions.Configuration.dll'
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests.ViewLibrary\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: . Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  - If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibrary.dll' exited with error: . Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
##[error]DiscoveryMessage : Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibraryProps.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  - If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Number of testcases discovered : 0
Discovered tests 0 from sources
=================================================================
##[error]The slice of type 'Discovery' is 'Aborted' because of the error : System.Exception: Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process for source(s) 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\Uno.UI.Tests.ViewLibraryProps.dll' exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\hostedtoolcache\windows\dotnet'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' was not found.
  - If this should be a framework-dependent app, add the 'D:\a\1\s\src\Uno.UI.Tests\bin\AnyCPU\Release\net7.0\testhost.runtimeconfig.json' file and specify the appropriate framework.
. Please check the diagnostic logs for more information.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.ThrowOnTestHostExited(IEnumerable`1 sources, Boolean testHostExited)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Received the command : Stop

nohwnd avatar May 26 '23 11:05 nohwnd

Additionally, did you move some of the projects from .NET Framework .NET? At least the one I was looking at is not referencing Microsoft.NET.Test.SDK, which will make it fallback on a fallback of test.sdk that is shipped with the console, and that might be imcompatible with the project, or broken in other ways because we are doing some assumptions there that might not be true.

Edit: Adding that reference to the Uno.Analyzers.Tests project makes it run the tests in my console.

nohwnd avatar May 26 '23 12:05 nohwnd

@nohwnd Indeed, we moved some of the tests to .NET 7, in an upcoming branch (that's where the tests fail). The analyzer tests are not super fancy, though they depend on Roslyn, so maybe that's one of the source for the dependency issue?

I'll add the reference and see if it helps on my end as well! Thanks for the troubleshooting!

jeromelaban avatar May 26 '23 15:05 jeromelaban

I've also finally found the underlying issue with not finding the manager in slot.

    private void StartTestRunOnConcurrentManager(
        IProxyExecutionManager proxyExecutionManager,
        IInternalTestRunEventsHandler eventHandler,
        TestRunCriteria testRunCriteria,
        bool initialized,
        Task? initTask)
    {
        if (testRunCriteria != null)
        {
            Task.Run(() =>
                {
                    if (!initialized)
                    {
                        if (!proxyExecutionManager.IsInitialized)
                        {
                            proxyExecutionManager.Initialize(_skipDefaultAdapters);
                        }

                        Interlocked.Increment(ref _runStartedClients);
                        proxyExecutionManager.InitializeTestRun(testRunCriteria, eventHandler);
                    }
                    else
                    {
                        initTask!.Wait();
                    }

                    EqtTrace.Verbose("ParallelProxyExecutionManager: Execution started. Started clients: " + _runStartedClients);

                    proxyExecutionManager.StartTestRun(testRunCriteria, eventHandler);
                })

This code kicks off work on each testhost that we start in parallel (which we also use when we pre-start testhost).

proxyExecutionManager.InitializeTestRun(testRunCriteria, eventHandler); attempts to start testhost process, and fails. Of course it does not throw an exception but instead it emits RunCompletedEvent, which is handled by the rest of the code and propagates back to the parallel handler, which grabs the slot that is holding the failed manager and clears it.

The method returns void, and because it does not throw we dont't know that the initialization failed, and continue executing. We again attempt to start testhost, because proxyExecutionManager.StartTestRun(testRunCriteria, eventHandler); again checks if testhost is initialized and if not it tries to start it up. We fail again, and again trigger the error handler that tries to clean up the slot. This time it won't find it of course because the slot is already cleared and possible re-purposed for a different manager.

On thing that threw me off was that the stacks look very similar in both places, so I did not notice that in one case we go directly into Initialize and in another we go into Start and then Initialize, even thought I was specifically thinking about that possibility, but did not compare the stacks in a diff tool unfortunately. That could have saved me half a day.

image

If you ask why it worked in the past, that is because previously we did not use those slots and just ignored any double event notifications because the "testhost is dead anyway".

In any case this is not a serious issue, as it can be reached only when the testhost already failed to start up.

nohwnd avatar May 26 '23 15:05 nohwnd

Thanks for the analysis! I can confirm that adding the missing package reference is fixing the issue.

jeromelaban avatar May 26 '23 21:05 jeromelaban

So what is the current state of this bug? What package reference do you mean @jeromelaban ?

PeterHevesi avatar Jun 01 '23 13:06 PeterHevesi

@PeterHevesi I added a reference to Microsoft.NET.Test.SDK.

jeromelaban avatar Jun 01 '23 14:06 jeromelaban

@PeterHevesi 17.6.1 was released today with the fix for the other problem, which can under some circumstances fix this problem as well. This problem is only happening after crash of testhost (based on the provided repro), the testhost crash needs to be solved, as this is just a by-product of that crash.

Why specifically it crashes in your case with 17.6.0 but not 17.5.0 I don't know, because I don't have a repro from you unfortunately.

nohwnd avatar Jun 01 '23 18:06 nohwnd

Test discovery and execution fails in Visual Studio, too (tested with 17.6.2 and 17.6.3).

  • use a fresh (git clean -xdf) clone of https://github.com/gitextensions/gitextensions.git
  • open GitExtensions.sln
  • build solution
  • run all tests In contrast to dotnet test, which executes the > 20000 testcases, only a few tests are discovered and run:

image

========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery starting
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
NUnit Adapter 3.17.0.0: Test discovery complete
========== Test discovery aborted: 448 Tests found in 1,1 sec ==========
Starting test discovery for requested test run
========== Starting test discovery ==========
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

========== Test discovery aborted: 0 Tests found in 15 ms ==========
========== Starting test run ==========
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\IntegrationTests\BugReporter.IntegrationTests\net6.0-windows\BugReporter.IntegrationTests.dll
   NUnit3TestExecutor discovered 1 of 1 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\BugReporter.Tests\net6.0-windows\BugReporter.Tests.dll
   NUnit3TestExecutor discovered 14 of 14 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\GitExtUtils.Tests\net6.0-windows\GitExtUtils.Tests.dll
   NUnit3TestExecutor discovered 260 of 260 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\AppVeyorIntegration.Tests\net6.0-windows\AppVeyorIntegration.Tests.dll
   NUnit3TestExecutor discovered 3 of 3 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\AzureDevOpsIntegration.Tests\net6.0-windows\AzureDevOpsIntegration.Tests.dll
   NUnit3TestExecutor discovered 48 of 48 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\ReleaseNotesGenerator.Tests\net6.0-windows\ReleaseNotesGenerator.Tests.dll
   NUnit3TestExecutor discovered 13 of 13 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\GitUIPluginInterfaces.Tests\net6.0-windows\GitUIPluginInterfaces.Tests.dll
   NUnit3TestExecutor discovered 27 of 27 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\ResourceManager.Tests\net6.0-windows\ResourceManager.Tests.dll
   NUnit3TestExecutor discovered 78 of 78 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
NUnit Adapter 3.17.0.0: Test execution started
Running selected tests in D:\Build\gitextensions3_dev\artifacts\Debug\bin\tests\UnitTests\DeleteUnusedBranches.Tests\net6.0-windows\DeleteUnusedBranches.Tests.dll
   NUnit3TestExecutor discovered 4 of 4 NUnit test cases
NUnit Adapter 3.17.0.0: Test execution complete
========== Test run finished: 448 Tests (448 Passed, 0 Failed, 0 Skipped) run in 2 sec ==========

mstv avatar Jun 13 '23 21:06 mstv

The currently released version of VS 17.6.3 does not have the fix yet unfortunately, it will be in 17.6.4 that should ship in few days I hope.

nohwnd avatar Jun 14 '23 08:06 nohwnd

The behavior with 17.6.4 is exactly the same (on my Ryzen 5700U with 16 virtual cores).

mstv avatar Jun 20 '23 20:06 mstv

Yeah the error is still there in 17.6.4, altough from 17.6.3 I think, tests discovery works for me, so I can use it without any problem, it's just that I still see that error

PeterHevesi avatar Jun 21 '23 08:06 PeterHevesi

I just ran into this issue as well in 17.6.4. I always had the reference to Microsoft.NET.Test.SDK in the project.

Tests run fine with dotnet test on command line, but the Test UI fails.

System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---
   

RevenantBob avatar Jun 21 '23 21:06 RevenantBob

We have the same problem too when using .NET6 but NOT when using .NET48 In both cases we use in the .csproj :

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />    
<PackageReference Include="MSTest.TestFramework" Version="2.1.1" />

[22/06/2023 2:57:35.978 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:35.986 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:36.018 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:36.022 pm] [Error] System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[22/06/2023 2:57:36.030 pm] [Error] System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

[22/06/2023 2:57:36.031 pm] [Error] Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Could not find testhost
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.GetTestHostProcessStartInfo(IEnumerable`1 sources, IDictionary`2 environmentVariables, TestRunnerConnectionInfo connectionInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, String runSettings)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
[22/06/2023 2:57:36.038 pm] [Error] System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.InitializeDiscovery(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler, Boolean skipDefaultAdapters)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
[22/06/2023 2:57:36.046 pm] [Error] System.AggregateException: One or more errors occurred. ---> System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
---> (Inner Exception #0) System.InvalidOperationException: The provided manager was not found in any slot.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.ClearCompletedSlot(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ParallelOperationManager`3.RunNextWork(TManager completedManager)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.HandlePartialDiscoveryComplete(IProxyDiscoveryManager proxyDiscoveryManager, Int64 totalTests, IEnumerable`1 lastChunk, Boolean isAborted)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelDiscoveryEventsHandler.HandleDiscoveryComplete(DiscoveryCompleteEventArgs discoveryCompleteEventArgs, IEnumerable`1 lastChunk)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyDiscoveryManager.DiscoverTests(DiscoveryCriteria discoveryCriteria, ITestDiscoveryEventsHandler2 eventHandler)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.Parallel.ParallelProxyDiscoveryManager.<>c__DisplayClass27_0.<DiscoverTestsOnConcurrentManager>b__0()
   at System.Threading.Tasks.Task.Execute()<---

[22/06/2023 2:57:36.049 pm]  ========== Test discovery aborted: 0 Tests found in 127,4 ms ==========

mgexo avatar Jun 22 '23 13:06 mgexo

The worst thing is, that it ends with "Test discovery aborted" instead of continuing with the other .dlls or other assemblies i.e. you have randomly missing tests even though maybe only one .dll has an issue

mgexo avatar Jun 22 '23 13:06 mgexo

A (Re-)Discover button would help. Or is there a way to trigger the discovery manually?

mstv avatar Jun 24 '23 10:06 mstv

A (Re-)Discover button would help. Or is there a way to trigger the discovery manually?

In Visual Studio Log/Output Window you can switch to the "Tests" Tab. You can see that it is always running the test discovery when you build a project. It even does the test discovery for all projects, not only the one that you build. So, triggering the test-discovery can be simply done by building (even if the build does nothing because all is build and just finishes right away)

That also means that we are now spammed with these errors and exceptions (mentioned above) in the background on each build...

mgexo avatar Jun 24 '23 13:06 mgexo

This started happening in one of our solutions. I was at 17.6.4. I've completely uninstalled VS2022 and .NET 6 and reinstalled 17.5.5 and the problem still persists.

SimonIpf avatar Jun 27 '23 14:06 SimonIpf

This started happening in one of our solutions. I was at 17.6.4. I've completely uninstalled VS2022 and .NET 6 and reinstalled 17.5.5 and the problem still persists.

I had to downgrade to 17.5.4 to get rid of the issue.

jrbye avatar Jun 27 '23 14:06 jrbye

Is this issue still going to be present in 17.7?

RevenantBob avatar Jun 27 '23 22:06 RevenantBob