首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误CS0234:命名空间'Microsoft‘中不存在类型或名称空间名称'VisualStudio’(您是否缺少程序集引用?

错误CS0234:命名空间'Microsoft‘中不存在类型或名称空间名称'VisualStudio’(您是否缺少程序集引用?
EN

Stack Overflow用户
提问于 2018-06-21 21:32:27
回答 2查看 12.3K关注 0票数 2

我正在使用Visual 2015专业版在本地机器上运行一些测试用例。我能够构建解决方案&在本地运行测试用例。

当我在TeamCity服务器上构建我的应用程序(构建代理也托管在TeamCity服务器上)时,我会收到以下错误:

代码语言:javascript
复制
Controllers\OneControllerTest.cs(5, 17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Controllers\LandingControllerTest.cs(2, 17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Controllers\TwoControllerTest.cs(5, 17): error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
Controllers\OneControllerTest.cs(15, 10): error CS0118: 'My_api.Test.OneControllerTest.TestInitialize()' is a 'method' but is used like a 'type' 
Controllers\OneControllerTest.cs(15, 10): error CS0246: The type or namespace name 'TestInitializeAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(22, 10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(22, 10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(39, 10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(39, 10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(40, 10): error CS0246: The type or namespace name 'ExpectedException' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(40, 10): error CS0246: The type or namespace name 'ExpectedExceptionAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(11, 6): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
Controllers\OneControllerTest.cs(11, 6): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\LandingControllerTest.cs(10, 10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
Controllers\LandingControllerTest.cs(10, 10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\LandingControllerTest.cs(7, 6): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
Controllers\LandingControllerTest.cs(7, 6): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\TwoControllerTest.cs(18, 10): error CS0118: 'My_api.Test.Controllers.TwoControllerTest.TestInitialize()' is a 'method' but is used like a 'type'
Controllers\TwoControllerTest.cs(18, 10): error CS0246: The type or namespace name 'TestInitializeAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\TwoControllerTest.cs(44, 10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
Controllers\TwoControllerTest.cs(44, 10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\TwoControllerTest.cs(60, 10): error CS0246: The type or namespace name 'TestMethod' could not be found (are you missing a using directive or an assembly reference?)
Controllers\TwoControllerTest.cs(60, 10): error CS0246: The type or namespace name 'TestMethodAttribute' could not be found (are you missing a using directive or an assembly reference?)
Controllers\TwoControllerTest.cs(13, 6): error CS0246: The type or namespace name 'TestClass' could not be found (are you missing a using directive or an assembly reference?)
Controllers\TwoControllerTest.cs(13, 6): error CS0246: The type or namespace name 'TestClassAttribute' could not be found (are you missing a using directive or an assembly reference?)

我使用以下nuget软件包:

代码语言:javascript
复制
<packages>
  <package id="Castle.Core" version="4.2.1" targetFramework="net45" />
  <package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
  <package id="Microsoft.UnitTestFramework.Extensions" version="2.0.0" targetFramework="net45" />
  <package id="Moq" version="4.8.0" targetFramework="net45" />
  <package id="MSTest.TestAdapter" version="1.3.2" targetFramework="net45" />
  <package id="MSTest.TestFramework" version="1.3.2" targetFramework="net45" />
  <package id="Newtonsoft.Json" version="9.0.1" targetFramework="net45" />
  <package id="System.Diagnostics.Contracts" version="4.0.1" targetFramework="net45" />
  <package id="System.Threading.Tasks.Extensions" version="4.4.0" targetFramework="net45" />
  <package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />
  <package id="Unity.AspNet.WebApi" version="4.0.1" targetFramework="net452" />
</packages>

我的team服务器框中安装了.net Framework4.0。我试图避免在team服务器,上安装Visual

造成这一错误的原因是什么?

EN

回答 2

Stack Overflow用户

发布于 2018-06-21 21:46:31

您需要安装visual才能在TeamCity构建服务器上运行单元测试。根据Team的文件,

需要在生成代理上安装适当的版本。

请参阅https://confluence.jetbrains.com/display/TCD10/MSTest+Support

票数 1
EN

Stack Overflow用户

发布于 2019-05-30 19:02:42

对于VS 2019年,我不得不更改目标框架

从目标框架4到4.6(最后版本)

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50977704

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档