45

I converted a VS2008 solution that contains some unit testing projects to VS2010. After the conversion I tried to compile the solution, but I'm getting the following error:

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

The namespace declaration cannot be found using Microsoft.VisualStudio.TestTools.UnitTesting;. In addition, I couldn't find the Microsoft.VisualStudio.QualityTools.UnitTestFramework assembly when I tried to add a new project reference.

Does anyone know what I'm doing wrong?

John Conde
  • 217,595
  • 99
  • 455
  • 496
CARLOS LOTH
  • 4,675
  • 3
  • 38
  • 44

6 Answers6

71

It's called Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.

You can find it in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • 1
    Thanks SLaks! That was correct. I had downloaded the SQLConfigurationSource project from Codeplex and tried to compile it . It failed because MS forgot to update their Documentation (AGAIN) with the new Library. Kudos!! –  Feb 02 '11 at 14:54
  • also: c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll – Four Oct 27 '11 at 14:12
22

I just had this problem as well, and with a Microsoft.Data.Schema library as well. The answer is correct, in that these library are on the machine and in the VS 10.0 directory.

The problem (at least for me) was that the solution was converted from VS2008 and the conversion utility targetted the project for .NET 3.5. Since the 10.0 library require .NET 4.0 they are not picked up by the compiler.

The solution is to either revert to use VS2008 where these resolve correctly; or to switch the project to compile for .NET 4.0 so you can use the available libraries.

Erik Brown
  • 236
  • 1
  • 2
6

For Visual Studio 2015 Users:

Had similar problem, but with upgrading a Prism WPF application StockTraderRI Unity version from Prism 2.2 to 5.0 using Visual Studio 2015. The 5.0 version used MEF and I needed the Unity version.

The steps I did was:

  1. Delete the assembly reference

enter image description here

  1. Add it back

enter image description here

  1. by selecting Assemblies | Extensions

enter image description here

  1. In the search box enter Microsoft.VisualStudio.QualityTools.UnitTestFramework

enter image description here

I had to do this for several test projects and the fastest way to repeat the adding is to just select Assemblies | Recent

enter image description here

VcDeveloper
  • 393
  • 4
  • 12
4

For VSTS 2010, make sure that you have these in the references:

  • Microsoft.VisualStudio.QualityTools.UnitTestFramework

  • Microsoft.VisualStudio.QualityTools.WebTestFramework (if you are doing web testing)

nyet
  • 83
  • 1
  • 9
0

Please go and download visual studio 2010 SP1. Install it. It will then allow you to change the frame work of testing project from previously default 4.0 to 3.5 and others. Just change the frame work to the frame work version of the project you want to test. Now the code will combine peacefully and you will be able to run the test.

Syed Salman Akbar
  • 767
  • 2
  • 8
  • 19
  • I get the feeling that Syed never tried his suggestion. It is impossible to convert the Target Framework of a Test project from 4.0 to 3.5 in Visual Studio 2010 SP1 without a significant hack. You literally have to trick VS into thinking that it is not a Test project, change the target framework and then change the project back to being a Test project. See here: [unable-to-change-target-framework-version-to-3-5-because-visual-studio-thinks-it-is-a-test-project](http://connect.microsoft.com/VisualStudio/feedback/details/553106/unable-to-change-target-framework-version-to-3-5-because-visual-stud –  Aug 28 '11 at 23:59
0

+Erik Brown is right, the problem is that VS2010 supports targeting your project to .NET 3.5 but doesn't support unit tests in a .NET 3.5 project.

However, since it makes sense to test your code under a framework that your code will be running on in production it is desirable to make this work. One easy way to make this work is to use NUnit instead and use Resharper to run the tests from within Visual Studio or the NUNit test runner. NUnit works with .NET v2.x - v4.x with a single set of binaries.

Scott Willeke
  • 8,884
  • 1
  • 40
  • 52