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:
我转换了一个VS2008解决方案,其中包含了对VS2010的一些单元测试项目。在转换之后,我尝试编译解决方案,但我得到了以下错误:
The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
类型或名称空间名称“VisualStudio”在名称空间“Microsoft”中不存在(您是否缺少一个程序集引用?)
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.
不能使用microsoft.visualstudio.testtools.unittest找到名称空间声明。另外,我找不到微软的visualstudioqualitytools。当我试图添加一个新的项目引用时,UnitTestFramework程序集。
Does anyone know what I'm doing wrong?
有人知道我做错了什么吗?
6 个解决方案
#1
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.
我也有这个问题,还有一个微软的数据。架构库。答案是正确的,因为这些库在机器上,在v10.0目录中。
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.
问题(至少对我来说)是,解决方案是由VS2008转换的,转换实用程序将这个项目的目标定位为。net 3.5。由于10.0库需要。net 4.0,所以编译器不会接收它们。
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.
解决方案是恢复使用VS2008,在那里正确地解决这些问题;或者转换项目来编译。net 4.0,这样您就可以使用可用的库了。
#2
71
It's called Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
.
它叫做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
.
你可以找到它在C:\Program Files (x86)\Microsoft Visual Studio IDE 10.0 \ Common7 \ \ PublicAssemblies \ Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll。
#3
5
For Visual Studio 2015 Users:
Visual Studio 2015用户:
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.
有类似的问题,但是使用visualstudio 2015升级Prism WPF应用StockTraderRI Unity版本从Prism 2.2到5.0。5.0版本使用了MEF,我需要Unity版本。
The steps I did was:
我的步骤是:
- Delete the assembly reference
- 删除程序集引用
- Add it back
- 将其重新添加
- by selecting Assemblies | Extensions
- 通过选择程序集|扩展。
- In the search box enter Microsoft.VisualStudio.QualityTools.UnitTestFramework
- 在搜索框中输入Microsoft.VisualStudio.QualityTools.UnitTestFramework。
I had to do this for several test projects and the fastest way to repeat the adding is to just select Assemblies | Recent
我必须为几个测试项目这样做,并且最快的重复添加的方法是选择最近的程序集|。
#4
4
For VSTS 2010, make sure that you have these in the references:
对于VSTS 2010,请确保在参考文献中有这些内容:
-
Microsoft.VisualStudio.QualityTools.UnitTestFramework
Microsoft.VisualStudio.QualityTools.UnitTestFramework
-
Microsoft.VisualStudio.QualityTools.WebTestFramework (if you are doing web testing)
Microsoft.VisualStudio.QualityTools。WebTestFramework(如果您正在进行web测试)
#5
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.
请下载visual studio 2010 SP1。安装它。然后,它将允许您将测试项目的框架工作从以前的默认4.0更改为3.5和其他。只需将框架工作更改为要测试的项目的框架工作版本。现在,代码将和平地结合在一起,您将能够运行测试。
#6
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.
+Erik Brown是对的,问题是VS2010支持将您的项目定位到。net 3.5,但不支持。net 3.5项目中的单元测试。
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.
但是,因为在代码将在生产环境中运行的框架下测试代码是有意义的,因此我们希望能够进行这项工作。一个简单的方法是使用NUnit,使用Resharper来运行Visual Studio或NUnit测试运行器的测试。NUnit与。net v2一起工作。x - v4。带有一组二进制文件的x。
#1
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.
我也有这个问题,还有一个微软的数据。架构库。答案是正确的,因为这些库在机器上,在v10.0目录中。
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.
问题(至少对我来说)是,解决方案是由VS2008转换的,转换实用程序将这个项目的目标定位为。net 3.5。由于10.0库需要。net 4.0,所以编译器不会接收它们。
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.
解决方案是恢复使用VS2008,在那里正确地解决这些问题;或者转换项目来编译。net 4.0,这样您就可以使用可用的库了。
#2
71
It's called Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
.
它叫做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
.
你可以找到它在C:\Program Files (x86)\Microsoft Visual Studio IDE 10.0 \ Common7 \ \ PublicAssemblies \ Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll。
#3
5
For Visual Studio 2015 Users:
Visual Studio 2015用户:
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.
有类似的问题,但是使用visualstudio 2015升级Prism WPF应用StockTraderRI Unity版本从Prism 2.2到5.0。5.0版本使用了MEF,我需要Unity版本。
The steps I did was:
我的步骤是:
- Delete the assembly reference
- 删除程序集引用
- Add it back
- 将其重新添加
- by selecting Assemblies | Extensions
- 通过选择程序集|扩展。
- In the search box enter Microsoft.VisualStudio.QualityTools.UnitTestFramework
- 在搜索框中输入Microsoft.VisualStudio.QualityTools.UnitTestFramework。
I had to do this for several test projects and the fastest way to repeat the adding is to just select Assemblies | Recent
我必须为几个测试项目这样做,并且最快的重复添加的方法是选择最近的程序集|。
#4
4
For VSTS 2010, make sure that you have these in the references:
对于VSTS 2010,请确保在参考文献中有这些内容:
-
Microsoft.VisualStudio.QualityTools.UnitTestFramework
Microsoft.VisualStudio.QualityTools.UnitTestFramework
-
Microsoft.VisualStudio.QualityTools.WebTestFramework (if you are doing web testing)
Microsoft.VisualStudio.QualityTools。WebTestFramework(如果您正在进行web测试)
#5
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.
请下载visual studio 2010 SP1。安装它。然后,它将允许您将测试项目的框架工作从以前的默认4.0更改为3.5和其他。只需将框架工作更改为要测试的项目的框架工作版本。现在,代码将和平地结合在一起,您将能够运行测试。
#6
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.
+Erik Brown是对的,问题是VS2010支持将您的项目定位到。net 3.5,但不支持。net 3.5项目中的单元测试。
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.
但是,因为在代码将在生产环境中运行的框架下测试代码是有意义的,因此我们希望能够进行这项工作。一个简单的方法是使用NUnit,使用Resharper来运行Visual Studio或NUnit测试运行器的测试。NUnit与。net v2一起工作。x - v4。带有一组二进制文件的x。