Where to find "Microsoft.VisualStudio.TestTools.UnitTesting" missing dll?

C#Visual Studio-2010Dll

C# Problem Overview


I am getting following error in my C# visual studio project:

>The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

I also tried to find the microsoft.dll file but couldn't get any reference. Am I searching the wrong DLL?

using Microsoft.VisualStudio.TestTools.UnitTesting;  
using Kya.MsFx.Services.Swiper;

namespace Kya.MsFx.Devices.Swiper.Test
{
[TestClass]
public class SwiperWindowTest
{

    private SwiperWebServiceHost m_SwiperWS = null;
    /// <summary>
    ///     start web service on a separate thread, so tests 
    ///     can be executed withut blocking the application thread
    /// </summary>
    [ClassInitialize]
    public void SetupSwiperTests() {

        m_SwiperWS = SwiperWebServiceHost.StartService();

    }

    /// <summary>
    /// Stop service started during class initialize and kill the thread
    /// </summary>
    [ClassCleanup]
    public void CleanupSwiperTests() {
        m_SwiperWS.Stop();
    }

    
    /// <summary>
    ///   simulate init, swipe, clear operations
    /// </summary>
    [TestMethod]
    public void TestSwiperService()
    {
        MessageBox.Show("test");
    }
}
}

C# Solutions


Solution 1 - C#

You have to add reference to

Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 

It can be found at C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\ directory (for VS2010 professional or above; .NET Framework 4.0).

or right click on your project and select: Add Reference... > .NET: or click Add Reference... > .NET:

Solution 2 - C#

I know this is old, this is what came up in my Google search. I needed to reference these packages on NuGet:

enter image description here

Solution 3 - C#

The DLL you're looking for that contains that namespace is

Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

Note that unit testing cannot be used in Visual Studio Express.

Solution 4 - C#

To resolve this issue, I had to do the following:

  1. Launch the Visual Studio Installer with administrative privileges
  2. If it prompts you to install updates to Visual Studio, do so before continuing
  3. When prompted, click the button to Modify the existing installation
  4. Click on the "Individual components" tab / header along the top
  5. Scroll down to the "Debugging and testing" section
  6. Check the box next to "Web performance and load testing tools"
  7. Click the Modify button on the bottom right corner of the dialog to install the missing DLLs

Once the DLLs are installed, you can add references to them using the method that Agent007 indicated in his answer.

Solution 5 - C#

There is also a nice [nuget package][1]. It will pull the dll to your packages folder. You will need to add the reference to the dll manually.

NOTE: This package is not an official Microsoft package.

[1]: http://www.nuget.org/packages/Microsoft.VisualStudio.QualityTools.UnitTestFramework/ "nuget package"

Solution 6 - C#

If you are using Visual Studio 2017 Community, the location is:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\ReferenceAssemblies\v2.0

The DLL you want is there: Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

Apparently it is located in the C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\ directory for Visual Studio 2010 Professional version, but take note that the 10.0 will change to correspond with the release year, i.e. VS 2013 was version 12.0, VS 2015 was version 14.0, VS 2017 is 15.0. (VS Express is not supported and would require installing the NUnit NuGet package, through the NuGet Package Manager, instead.)

You go to References, right-click, select Add Reference, Browse. Navigate to the path, then double-click the file.

Then, you need a using statement at the top of your Unit Test class:

using Microsoft.VisualStudio.TestTools.UnitTesting;

Solution 7 - C#

I.e. for Visual Studio 2013 I would reference this assembly:

> Microsoft.VisualStudio.Shell.14.0.dll

You can find it i.e. here:

> C:\Program Files (x86)\Microsoft Visual Studio > 12.0\Common7\IDE\Extensions\BugAid Software\BugAid\1.0

and don't forget to implement:

> using Microsoft.VisualStudio;

Solution 8 - C#

If you came here because your VSTS build job is failing with the above error message. Ensure that you are using at least version 2.* of the nuget task to restore your packages.

Solution 9 - C#

I got this problem after moving a project and deleting it's packages folder. Nuget was showning that MSTest.TestAdapter and MSTest.TestFramework v 1.3.2 was installed. The fix seemed to be to open VS as administrator and build After that I was able to re-open and build without having admin priviledge.

Solution 10 - C#

Add a reference to 'Microsoft.VisualStudio.QualityTools.UnitTestFramework" NuGet packet and it should successfully build it.

Solution 11 - C#

With Visual Studio 2019, running a .net core 3.1 project, you will need to install the latest test framework to resolve the error.

Easiest way to accomplish this is by hovering the browser over a [Test] annotation (underlined in red) and select suggested fixes. The one needed is to "search for and install the latest test framework."

Solution 12 - C#

Simply Refer this URL and download and save required dll files @ this location:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies

URL is: https://github.com/NN---/vssdk2013/find/master

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAmit PalView Question on Stackoverflow
Solution 1 - C#Agent007View Answer on Stackoverflow
Solution 2 - C#Jesse SierksView Answer on Stackoverflow
Solution 3 - C#Joachim IsakssonView Answer on Stackoverflow
Solution 4 - C#S. HooleyView Answer on Stackoverflow
Solution 5 - C#RashackView Answer on Stackoverflow
Solution 6 - C#vapcguyView Answer on Stackoverflow
Solution 7 - C#cregView Answer on Stackoverflow
Solution 8 - C#Jim WolffView Answer on Stackoverflow
Solution 9 - C#KirstenView Answer on Stackoverflow
Solution 10 - C#Sanjeev KumarView Answer on Stackoverflow
Solution 11 - C#Stanley TonkonogyView Answer on Stackoverflow
Solution 12 - C#VeerView Answer on Stackoverflow