VS2017 Failed to load the file or assembly Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll or one of its dependencies

When trying to open an older solution in VS2017 there is an old Unit Test project that creates problems when creating.

I keep getting the following error while creating this test project:

Could not load file or assembly: /// C: \ Projects \ MyProj \ Test \ DAL \ UnitTestProj \ Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 'or one of its dependencies. The system cannot find the specified file.

I checked the project links and it seems to be referencing Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll . In addition, there are no code errors. How could I ever find out if this is one of his addictions that he cannot find?

+12
visual-studio visual-studio-2017 vs-unit-testing-framework
source share
3 answers

I had a similar problem (with the optional The "BuildShadowTask" task failed unexpectedly message) with a project originally developed with VS2010, and I had to spend the last few hours exploring yet another inherited aspect of the build process.

There is a good chance that you are dealing with a private accessor file ( .accessor ) that was deprecated in VS2012 ( source - 404). This was preceded by an announcement from the VS2010 team that they no longer worked on these features.

There is also the possibility that you are simply dealing with erroneous links to the wrong version of UnitTestFramework, but NuGet recovery should fix this. If not, see this GitHub thread for a possible fix (manually change the ref to the shared folder) or go to the new MSTest.TestAdapter and MSTest.TestFramework (see the MSDN support thread ).

Decision

  • Edit unit test .csproj and change the item links from <Shadow Include="Test References\namespace.accessor" /> to <None Include="Test References\namespace.accessor" /> ( Shadow => None ).
  • Even better, just delete all .accessor files from the unit test of the Test References project.

Ideally, you also rewrite your unit tests to remove references to private methods, either by re-archiving to separate the problems, or by changing the properties to internal and using "friend" using InternalsVisibleToAttribute .


For those who, for some reason, continue to support testing of private methods, the same post provides the following logical questions, "What is available for me then?" :

For those who want to continue testing the internal APIs, you have three options:

  • Use the Microsoft.VisualStudio.TestTools.UnitTesting.PrivateObject class to help access internal and private APIs in your code. This can be found in the Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll assembly.
  • Create a reflection infrastructure that can mirror your code to access internal or private APIs.
  • If the code you are trying to access is internal, you can access your APIs using InternalsVisibleToAttribute so that your test code can access the internal APIs.

However, there is no good replacement for Code Generation for new features added by lanugage commands. You can create TestMethod stubs and then remove the internal code. You only need to save the stub.


Further readings / sources that helped me put this together:

+26
source share

Right-click on the folder with links to the project. Add Link> Assemblies> Extensions. Check out Microsoft.VisualStudio.QualityTools.UnitTestFramework 10.1 and uncheck any older version.

+1
source share

Visual Studio Enterprise 2015, when I tried to add a load test, it displays the message "Unable to find assembly." Microsoft.VisualStudio.QualityTools.LoadTest, version = 14.0.0.0, culture = neutral, PublicKeyToken = b03f5f7f11d50a3a

The assembly load test installed in open assemblies displays as version 10.0.0.0, but it wasn’t in the GAC,

Most likely, he received only 10.1.0.0. Install 10.0.0.0 and restart VS 2015, solving my problem.

DLL path ...... \ Program Files (x86) \ Microsoft Visual Studio 14.0 \ Common7 \ IDE \ PublicAssemblies \ Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

.CSProj reference version

0
source share