testfx: Test run failed with Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel.dll' or one of its dependencies. Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
Description
Not able to run tests
Steps to reproduce
Create MSTest Desktop Unit test project Add app.config file with content similar to following
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<appSettings>
<?ap-config target="/configuration/appSettings/add[@key='AzureKeyVaultConnectionString']/@value" value="VaultUrl=https://TestAnBKV02.vault.azure.net:443; ServicePrincipalId=https://TestDocumentAdjustment; StoreName=My; StoreLocation=LocalMachine; ThumbPrint=72372785dab2b10f353046ba5785c64a3df426f8;" when="@environment='Redmond-CI'" ?>
</appSettings>
</configuration>
Run tests
Expected behavior
Tests should run.
Actual behavior
test output pane content:
[6/20/2017 6:42:11 PM Informational] ------ Load Playlist started ------
[6/20/2017 6:42:11 PM Informational] ========== Load Playlist finished (0:00:00.0050034) ==========
[6/20/2017 6:43:59 PM Informational] ------ Discover test started ------
[6/20/2017 6:43:59 PM Warning] Could not load file or assembly 'file:///C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO\2017\ALM\ENTERPRISE\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll' or one of its dependencies. Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
[6/20/2017 6:43:59 PM Informational] ========== Discover test finished: 0 found (0:00:00.2929448) ==========
[6/20/2017 7:05:18 PM Informational] ------ Discover test started ------
[6/20/2017 7:05:18 PM Informational] ========== Discover test finished: 0 found (0:00:00.0510373) ==========
EqtTrace content:
W, 51832, 14, 2017/06/20, 14:59:10.852, 1686621383696, vstest.executionengine.exe, MSTestDiscoverer.TryGetTests: Failed to discover tests from C:\Users\samadala\Desktop\DRI\cloudbuild\MSASG_AnB_retail\QTestRerun_new\ClientCenter.Common.Test.dll\ClientCenter.Common.Test.dll. Reason:System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\samadala\Desktop\DRI\cloudbuild\MSASG_AnB_retail\Microsoft.VisualStudio.Test.14.0.25420.25\BinaryDeployment\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll' or one of its dependencies. Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))
File name: 'file:///C:\Users\samadala\Desktop\DRI\cloudbuild\MSASG_AnB_retail\Microsoft.VisualStudio.Test.14.0.25420.25\BinaryDeployment\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll'
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.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)
at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)
at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)
at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
at System.AppDomain.CreateInstanceFromAndUnwrap(String assemblyName, String typeName)
at Microsoft.VisualStudio.TestPlatform.ObjectModel.EqtTrace.SetupRemoteEqtTraceListeners(AppDomain childDomain)
at Microsoft.VisualStudio.TestPlatform.MSTestFramework.AppDomainIsolatedHost.CreateEnumerator(String assemblyFileName, IRunSettings runSettings)
at Microsoft.VisualStudio.TestPlatform.MSTestFramework.AssemblyEnumeratorWrapper.GetTests(String assemblyFileName, IDiscoveryContext discoveryContext, ICollection`1& warnings)
at Microsoft.VisualStudio.TestPlatform.Extensions.VSTestIntegration.UnitTestDiscoverer.DiscoverTests(String source, IDiscoveryContext discoveryContext, IMessageLogger logger, ITestCaseDiscoverySink discoverySink)
Repro project: AssemblyLoadUnitTestProject.zip
Enable fusion logs show following failure:
<meta http-equiv="Content-Type" content="charset=unicode-1-1-utf-8"><!-- saved from url=(0015)assemblybinder: --><html><pre>
*** Assembly Binder Log Entry (6/20/2017 @ 6:10:24 PM) ***
The operation failed.
Bind result: hr = 0x80004005. Unspecified error
Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\clr.dll
Running under executable C:\Users\samadala\Desktop\DRI\cloudbuild\MSASG_AnB_retail\Microsoft.VisualStudio.Test.14.0.25420.25\BinaryDeployment\vstest.executionengine.exe
--- A detailed error log follows.
=== Pre-bind state information ===
LOG: Where-ref bind. Location = C:\Users\samadala\Desktop\DRI\cloudbuild\MSASG_AnB_retail\Microsoft.VisualStudio.Test.14.0.25420.25\BinaryDeployment\Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
LOG: Appbase = file:///C:/Users/samadala/Desktop/DRI/cloudbuild/MSASG_AnB_retail/QTestRerun_new/ClientCenter.Common.Test.dll
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : (Unknown).
===
LOG: This bind starts in LoadFrom load context.
WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with Assembly.Load().
LOG: Download of application configuration file was attempted from file:///C:/Users/samadala/Desktop/DRI/cloudbuild/MSASG_AnB_retail/QTestRerun_new/ClientCenter.Common.Test.dll/ClientCenter.Common.Test.dll.config.
LOG: Found application configuration file (C:\Users\samadala\Desktop\DRI\cloudbuild\MSASG_AnB_retail\QTestRerun_new\ClientCenter.Common.Test.dll\ClientCenter.Common.Test.dll.config).
ERR: There was an error parsing XML (hr = 0x80004005).
ERR: Parse XML memory stream failed.
ERR: Unrecoverable error occurred during pre-download check (hr = 0x80004005).
</pre></html>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (9 by maintainers)
Commits related to this issue
- Merge pull request #203 from smadala/fixtestcasefilter Fix for testcasefilter is not working for netcore — committed to singhsarab/testfx by codito 8 years ago
FYI, this is also an issue in Apache Avro when porting it’s C# language library and unit tests to .net standard 2.0.
Workaround
Downgrade Microsoft.NET.Test.Sdk to 15.3.0
Expectations
Behavior should be consistent across platforms. At the very minimum, reflection should be exception-free on non-windows OS’s.
Details
It happens during deserialization when you want to reflect on all current assemblies to find the type required to materialize; specifically at
assembly.GetTypes()
(source) when assembly isMicrosoft.VisualStudio.TestPlatform.ObjectModel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
The exception is only seen on Linux and Mac (not on Windows) and is:
Specifically,
LoaderExceptions
is