I was trying to get some tests running inside a console application
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.TestTools.UnitTesting; // this doesn't work
The error I'm getting is:
The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Yet it all works in a seperate test p开发者_JAVA技巧roject:
Question: What is different?
You need to change the target framework of the ConsoleApplication to be .Net Framework 4
(NOT .NET Framework 4 Client Profile
)
If you are targeting the .NET Framework 4 Client Profile, you cannot reference an assembly that is not in the .NET Framework 4 Client Profile. Instead you must target the .NET Framework 4.
You can't reference Microsoft.VisualStudio.QualityTools.UnitTestFramewor
, because it is not part of the client profile framework.
EDIT: Sorry, you have that already ...
You need the reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework
in your console application.
You can add it from C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies
The default Visual Studio Test project has this reference by default...
You can create test project from visual studio and change the project output type from class library to console application.
Regards Aseem Bansal
精彩评论