Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

unit testing - Type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft'

I can see from here, that the namespace Visual Studio should exist within namespace Microsoft, yet I get that error and none of my tests are working!

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

I am using Visual Studio 2012 with Windows 8.1 (all updated).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I got this error when trying to build a project in TFS. These steps fixed it:

  • remove reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework
  • add nuget MSTest.TestFramework
  • add nuget MSTest.TestAdapter (optional but needed to run tests inside Visual Studio)

The above steps caused this element to be removed from my .csproj file:

<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework" />

And these two were added instead:

    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesMSTest.TestFramework.2.1.1lib
et45Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
      <HintPath>..packagesMSTest.TestFramework.2.1.1lib
et45Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
    </Reference>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...