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.

Test Explorer fails to show tests. Tests output: "The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)"

See original GitHub issue

Description

I cloned a private Git repo on my local machine. The solution comprises of several projects all targeting .NET 4.6.2. I built the solution which pulled-in some NuGet packages, including MSTest.TestAdapter, 1.1.18 and MSTest.TestFramework, 1.1.18. There is a test project in the solution with several [TestClass]/[TestMethod] tests. The solution builds successfully, however the Test Explorer window is empty. On a coworker’s machine running VS2015 the Test Explorer is populated correctly.

In the Output window’s Test output I see the following:

------ Discover test started ------ The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047) ========== Discover test finished: 0 found (0:00:00.1886778) ==========

Steps to reproduce

I have no specific reproduction steps - it happened spontaneously on my machine. Restarting VS, cleaning the project output and TestResults directory, and closing+reopening the Test Explorer window has no effect.

Expected behavior

The tests in the project should appear in Test Explorer.

Actual behavior

No tests appear in Test Explorer, and an error message in the Output window.

Environment

Please share additional details about the test environment. Operating system, Build version of vstest.console, Package version of MSTest framework and adapter

  • Windows 10 x64 Enterprise, Creators Update
  • Visual Studio 2017 Enterprise, 15.2
  • MSTest package version 1.1.18
  • Projects targeting .NET 4.6.2
  • I have two copies of vstest.console installed:
    • C:\Program Files (x86)\Microsoft Visual Studio 15.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe - 15.0.26228.0 - 142KB
    • C:\Program Files (x86)\Microsoft Visual Studio 15.0\Common7\IDE\Extensions\TestPlatform\vstest.console.exe - 15.0.0.0 - 117KB

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:8
  • Comments:101 (45 by maintainers)

github_iconTop GitHub Comments

18reactions
daipluspluscommented, Sep 8, 2017

I generated the fusion logs - I had a quick look but I couldn’t see any errors.

I do have another test project that works fine and its tests do appear in the Test Explorer window - so I compared the two projects. I noticed they’re both .NET Framework 4.6.2 projects, however the working project has a reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework which is being pulled from C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll - whereas the non-working project has a reference to Microsoft.VisualStudio.TestPlatform.TestFramework which is being pulled from (solution root)\packages\MSTest.TestFramework.1.1.18\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll.

Indeed, the working project is using a standard Visual Studio Test project which came with its own VS-coupled references, while the non-working project is using the NuGet “MSTest V2” assemblies instead.

So why is MSTest V2 not working all of a sudden?

TL;DR Workaround:

  1. Remove the NuGet package references and project assembly references to Microsoft.VisualStudio.TestPlatform.TestFramework.
  2. Replace them with a reference to your Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll assembly instead, which is located inside your Visual Studio installation directory (Common7\IDE\PublicAssemblies).
8reactions
MartinFcommented, Apr 4, 2018

Just want to report that I had the same problems in a newly created project. The app.config used to be empty, but after installing some packages assemblybinding’s must have gotten added, which was causing the problem.

The solution was simple - I deleted the whole runtime section and cleared the output folders (bin, obj and TestResults), then it was working again. Tried adding the assemblybindings again and got the same error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Exception from HRESULT: 0x80131047
So the message should be "long assembly name required" with a link to the document. The current message is totally misleading. – Paul...
Read more >
Unit Test Adapter threw exception:The given assembly name ...
Unit Test Adapter threw exception:The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047).
Read more >
Test Explorer fails to show tests | HRESULT: 0x80131047
This issue has been fixed and is now available in our latest update. You can download the update via the in-product notification or...
Read more >
The given assembly name or codebase was invalid. ...
1 Answer. The problem was in my module tag in web. config file. It must be the full assembly name, not just the...
Read more >
0x80131047) " error executing aginst .eds compiled with ...
eds compiled with Assembly.dll. "The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)" error executing aginst .
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