question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot execute tests when DisableAppDomain is true

See original GitHub issue

Describe the bug

An exception occurred while invoking executor ‘executor://mstestadapter/v2’: Could not load file or assembly

Steps To Reproduce

Steps are the same as in #1493.

The problem happens with both 3.0.2 and 4.0.0-preview-20221222-4. Unfortunately, this time I cannot create a simple project to re-create the problem, but it is reproducible on our pipelines. One thing I noticed Fusion is showing Microsoft.TestPlatform.CoreUtilities is being loaded from test adapter path instead of vstest.console.exe location. Settings DisableAppDomain to false fixes the problem.

The log:

An exception occurred while invoking executor 'executor://mstestadapter/v2': Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources, Version=14.0.0.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack trace:
Server stack trace: 
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
   at System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
   at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
   at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
   at System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Resource.get_MissingDeploymentDependency()
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetDependentAssembliesInternal(String assemblyString, IList`1 result, ISet`1 visitedAssemblies, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.ProcessChildren(Assembly assembly, IList`1 result, ISet`1 visitedAssemblies, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetDependentAssembliesInternal(String assemblyString, IList`1 result, ISet`1 visitedAssemblies, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.ProcessChildren(Assembly assembly, IList`1 result, ISet`1 visitedAssemblies, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetDependentAssembliesInternal(String assemblyString, IList`1 result, ISet`1 visitedAssemblies, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.ProcessChildren(Assembly assembly, IList`1 result, ISet`1 visitedAssemblies, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetFullPathToDependentAssemblies(String assemblyPath, IList`1& warnings)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetFullPathToDependentAssemblies(String assemblyPath, IList`1& warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AssemblyUtility.GetFullPathToDependentAssemblies(String assemblyPath, String configFile, IList`1& warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtility.AddDependencies(String testSource, String configFile, IList`1 deploymentItems, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtility.AddDependenciesOfDeploymentItem(String deploymentItemFile, IList`1 filesToDeploy, IList`1 warnings)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtilityBase.Deploy(IList`1 deploymentItems, String testSource, String deploymentDirectory, String resultsDirectory)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtilityBase.Deploy(String source, IRunContext runContext, ITestExecutionRecorder testExecutionRecorder, IList`1 deploymentItems, TestRunDirectories runDirectories)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.TestDeployment.Deploy(IEnumerable`1 tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle, TestRunCancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithSources.InvokeExecutor(LazyExtension`2 executor, Tuple`2 executorUriExtensionTuple, RunContext runContext, IFrameworkHandle frameworkHandle)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.<>c__DisplayClass46_0.<RunTestInternalWithExecutors>b__0()
   at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.<>c__DisplayClass0_0.<Run>b__0()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.TestPlatform.PlatformAbstractions.PlatformThread.Run(Action action, PlatformApartmentState apartmentState, Boolean waitForCompletion)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.TryToRunInStaThread(Action action, Boolean waitForCompletion)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTestInternalWithExecutors(IEnumerable`1 executorUriExtensionMap, Int64 totalTests)
Inner exception: Could not load file or assembly 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
Stack trace:
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.<>c__DisplayClass25_0.<OnResolveInternal>b__0()
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.SafeLog(String assemblyName, Action loggerAction)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.OnResolveInternal(Object senderAppDomain, ResolveEventArgs args, Boolean isReflectionOnly)
   at Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.OnResolve(Object sender, ResolveEventArgs args)
   at System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)

AB#1827543

Issue Analytics

  • State:closed
  • Created 7 months ago
  • Comments:52 (23 by maintainers)

github_iconTop GitHub Comments

2reactions
avivanoffcommented, Jun 3, 2023

@Evangelink, @engyebrahim, so far, all test runs that used to fail are succeeding. Thank you.

1reaction
avivanoffcommented, May 29, 2023

@Evangelink, the tests always worked because they were executing in app domains. It is when I disabled the app domain the tests started to fail.

Read more comments on GitHub >

github_iconTop Results From Across the Web

NUnit is ignoring DomainUsage in the runsettings file
The DisableAppDomain setting was added to allow Visual Studio to force NUnit to try to run without using an AppDomain . The Test...
Read more >
DisableAppDomain true increases discovery and ...
Create a Xunit tests with Disable App Domain setting runsetting. Run the tests with value as true and false. Expected behavior. Improved number ......
Read more >
vstest-docs/docs/configure.md at main
This document covers configuration of a test run in the test platform ... DisableAppDomain=true if you're using dotnet test to execute tests ......
Read more >
Upgrading to MSTest.Framework 2.2.4 from 2.1.2 cant find ...
Consistently, all the time. If I right click the project, it fails with the same message every time having not detected one of...
Read more >
Configure unit tests by using a .runsettings file
Learn how to use the .runsettings file in Visual Studio to configure unit tests that are run from the command line, from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found