AxoCover
AxoCover copied to clipboard
FileNotFoundExction: Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources,
I have an odd problem that I can't really reproduce in a sample app.
If I run / debug / cover all tests or even multiple tests at once, every test fails with a FileNotFoundException
The test method MyTest1 throw an exception:
System.IO.FileNotFoundException: Could not load file or assembly `MyApp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
I tracked down the issue to the following conditions:
- MyApp.Tests project references MyApp
- A test method uses the
DeploymentItemattribute.
This is strange, all tests fail, even if they don't have an DeploymentItem itself.
- Removing the
DeploymentItemattribute and all tests run (the ones relying on the DeploymentItems fail, but without the FileNotFoundException, others run fine) - Replacing the calls to MyApp in one test methods body with
Assert.IsTrue(true)soMyAppwon't be used, and it will pass. - Running one test without a
DepoymentItemindividually passes.
I even added every indirect dependency from myapp, but without a result.
I am using AxoCover with MsTest V2 (Version1.3.0-beta2, Adapter Mode Standard and Redirect dlls of test framework assemblies enabled).
Anyway, I believe the FileNotFoundException has something to do with the Redirect dlls of test framework assemblies not redirecting the satellite asemblies and the exception is thrown while generating a usefull error message:

bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Resource.get_MissingDeploymentDependency()
Could you please extend the file redirection feature for
- Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources.dll
- Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources.dll
- Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
Here is the full stack trace
Test execution started.
___
/ \
| |
\ /
/ \
/ \
___/ \___
/ \
| _______ |
\___/ \___/
AxoCover Test Runner Console
(c) Peter Major 2017
> Executing tests...
| Runner version is 1.1.385.0.
| We are on x86 platform.
SerializableException: Die Datei oder Assembly "AxoCover.Runner.XmlSerializers, Version=1.1.385.0, Culture=neutral, PublicKeyToken=null" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
bei System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
bei System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
SerializableException: Die Datei oder Assembly "AxoCover.Runner.XmlSerializers" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
bei System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
bei System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
| File redirection is enabled for the following files:
| C:\Users\juergen\AppData\Local\Microsoft\VisualStudio\15.0_60087b23\Extensions\0vmhvlaa.i4p\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
| C:\Users\juergen\AppData\Local\Microsoft\VisualStudio\15.0_60087b23\Extensions\0vmhvlaa.i4p\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
| C:\Users\juergen\AppData\Local\Microsoft\VisualStudio\15.0_60087b23\Extensions\0vmhvlaa.i4p\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
| C:\Users\juergen\AppData\Local\Microsoft\VisualStudio\15.0_60087b23\Extensions\0vmhvlaa.i4p\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.dll
| C:\Users\juergen\AppData\Local\Microsoft\VisualStudio\15.0_60087b23\Extensions\0vmhvlaa.i4p\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
| Setting up file redirection hooks...
| File redirection hooks are enabled.
>> Loading assembly from C:\Users\juergen\AppData\Local\Microsoft\VisualStudio\15.0_60087b23\Extensions\0vmhvlaa.i4p\MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll...
|| Loaded executor: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor
<< Assembly loaded.
>> Running executor: Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor...
|| Processing tests in: C:\Users\juergen\Source\Repos\MyApp\tests\MyApp.Test\bin\Debug\MyApp.Test.dll...
SerializableException: Die Datei oder Assembly "Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources, Version=14.0.0.0, Culture=de-DE, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
Server stack trace:
bei System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
bei System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
bei System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
bei System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
bei System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
bei System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
bei System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Resource.get_MissingDeploymentDependency()
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetDependentAssembliesInternal(String assemblyString, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.ProcessChildren(Assembly assembly, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetDependentAssembliesInternal(String assemblyString, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.ProcessChildren(Assembly assembly, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetFullPathToDependentAssemblies(String assemblyPath, IList`1& warnings)
bei System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
bei System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
SerializableException: Die Datei oder Assembly "Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.<>c__DisplayClass24_0.<OnResolveInternal>b__0()
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.SafeLog(String assemblyName, Action loggerAction)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.OnResolveInternal(Object senderAppDomain, ResolveEventArgs args, Boolean isReflectionOnly)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.OnResolve(Object sender, ResolveEventArgs args)
bei System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
Test Run deployment issue: Failed to deploy dependencies for test storage 'C:\Users\juergen\Source\Repos\MyApp\tests\MyApp.Test\bin\Debug\MyApp.Test.dll': System.IO.FileNotFoundException: Die Datei oder Assembly "Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources, Version=14.0.0.0, Culture=de-DE, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abh寧igkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
Dateiname: "Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources, Version=14.0.0.0, Culture=de-DE, PublicKeyToken=b03f5f7f11d50a3a" ---> System.IO.FileNotFoundException: Die Datei oder Assembly "Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
Dateiname: "Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.<>c__DisplayClass24_0.<OnResolveInternal>b__0()
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.SafeLog(String assemblyName, Action loggerAction)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.OnResolveInternal(Object senderAppDomain, ResolveEventArgs args, Boolean isReflectionOnly)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.AssemblyResolver.OnResolve(Object sender, ResolveEventArgs args)
bei System.AppDomain.OnAssemblyResolveEvent(RuntimeAssembly assembly, String assemblyFullName)
Server stack trace:
bei System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
bei System.Reflection.RuntimeAssembly.InternalGetSatelliteAssembly(String name, CultureInfo culture, Version version, Boolean throwOnFileNotFound, StackCrawlMark& stackMark)
bei System.Resources.ManifestBasedResourceGroveler.GetSatelliteAssembly(CultureInfo lookForCulture, StackCrawlMark& stackMark)
bei System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark)
bei System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark)
bei System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents)
bei System.Resources.ResourceManager.GetString(String name, CultureInfo culture)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Resource.get_MissingDeploymentDependency()
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetDependentAssembliesInternal(String assemblyString, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.ProcessChildren(Assembly assembly, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetDependentAssembliesInternal(String assemblyString, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.ProcessChildren(Assembly assembly, IList`1 result, IList`1 visitedAssemblies, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetFullPathToDependentAssemblies(String assemblyPath, IList`1& warnings)
bei System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
bei System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
bei System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
bei System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetFullPathToDependentAssemblies(String assemblyPath, IList`1& warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AssemblyUtility.GetFullPathToDependentAssemblies(String assemblyPath, String configFile, IList`1& warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtility.AddDependencies(String testSource, String configFile, IList`1 deploymentItems, IList`1 warnings)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.DeploymentUtility.ProcessNewStorage(String testSource, IList`1 deploymentItems, IList`1 warnings)
SerializableException: Element nicht gefunden. (Ausnahme von HRESULT: 0x80070490)
SerializableException: Die Datei oder Assembly "Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abhängigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetTargetFrameworkVersionStringFromPath(String path)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetTargetFrameworkVersionStringFromPath(String path)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AppDomainUtilities.GetTargetFrameworkVersionString(String testSourcePath)
Failed MyApp.Tests.TestClass1.TestMethod1
Failed MyApp.Tests.TestClass1.TestMethod2
Failed MyApp.Tests.TestClass1.TestMethod3
<< Executor finished.
| File redirection rules are cleared.
< Test execution finished.
Shutting down...
Exiting...
SerializableException: Der E/A-Vorgang wurde wegen eines Threadendes oder einer Anwendungsanforderung abgebrochen
bei System.ServiceModel.Channels.SocketConnection.HandleReceiveAsyncCompleted()
Test execution finished.
I will check this at the weekend. Until that I suggest you use MSTest V2 1.2.1 as latest AxoCover, which should resolve the issue. If you are not at the latest plese update.
You may refer to this file to see the current versions of the test frameworks: https://github.com/axodox/AxoCover/blob/master/AxoCover.Dependencies/packages.config
I'm on version 1.3.0-beta2 because of in assembly parallel test execution.
After diging around in your code I found a workaround:
https://github.com/axodox/AxoCover/blob/master/AxoCover/Models/Testing/Adapters/MsTest2Adapter.cs#L48
public MsTest2Adapter(IEditorContext editorContext)
{
_assemblyPath = Path.Combine(AxoCoverPackage.PackageRoot, @"MSTestAdapter\Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll");
_redirectedAssemblies = Directory.GetFiles(Path.GetDirectoryName(_assemblyPath), "*.dll");
}
Redirected assemblies are evaluated at runtime by scanning C:\Users\...\AppData\Local\Microsoft\VisualStudio\15.0_60087b23\Extensions\...\MSTestAdapter.
I copied the satellite assemblies to this location before but it turns out I have to restart visual studio for this to take effect.
Maybe in a future release you could determine the assemblies to redirect by using
var _assembly = Assembly.GetAssembly("Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll");
var _assemblyPath = _assembly.Location;
var _redirectedAssemblies = Directory.GetFiles(Path.GetDirectoryName(_assemblyPath), "*.dll", SearchOption.AllDirectories);`
or by using
Assembly.GetAssembly("Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll").GetReferencedAssembylies() (while excluding framework assemblies.
It turns out the real exception was just
SerializableException: Die Datei oder Assembly "Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" oder eine Abh„ngigkeit davon wurde nicht gefunden. Das System kann die angegebene Datei nicht finden.
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetTargetFrameworkVersionStringFromPath(String path)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Deployment.AssemblyLoadWorker.GetTargetFrameworkVersionStringFromPath(String path)
bei Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Utilities.AppDomainUtilities.GetTargetFrameworkVersionString(String testSourcePath)
But this was just logged and the tests passed.
Anyway, I copied the file Microsoft.VisualStudio.TestPlatform.ObjectModel.dll from <extensionpath>\TestPlatform to <extensionpath>\MSTestAdapter and now the stacktrace is gone.
FYI, this is the content in my <extensionpath>\MSTestAdapter folder now.
02.05.2018 11:36 114.528 Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
15.01.2018 02:05 31.760 Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.resources.dll
02.05.2018 11:36 122.264 Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
02.05.2018 11:36 25.024 Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface.dll
15.01.2018 02:05 25.160 Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.resources.dll
02.05.2018 11:36 135.528 Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
02.05.2018 11:36 69.968 Microsoft.VisualStudio.TestPlatform.TestFramework.dll
02.05.2018 11:36 39.808 Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
15.01.2018 02:05 27.640 Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll