繁体   English   中英

Intellisense和类库的问题

[英]Issues with Intellisense and class library

我正在使用Visual Studio 2013.我正在尝试使用本教程开始单元测试。

我添加了一个类库和对MVC的引用。 但是,Intellisense / Autocompletion在我的类库中无法正常工作。 目前,这是我在测试类中的所有代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using System.Web.Mvc;
using System.Web;
using Application_Portal;
using Application_Portal.Controllers;

namespace ApplicationPortalTests
{
    [TestFixture]
    public class HomeControllerTest
    {
        HomeController home = new HomeController();
    }
}

Intellisense似乎没有识别home变量(没有建议的属性等)。键入home.Index()会出现以下错误:

ApplicationPortalTests.HomeControllerTest.home' is a 'field' but is used like a 'type'  

此外,它似乎甚至没有识别“var”(如var result = ...)。 相反,当我输入var并命中空格时,它会将其自动填充为EnvironmentVariableTarget。

我已经尝试过清理和重建项目,关闭并重新打开Visual Studio,但没有成功。

问题可能是什么? 我很感激任何建议。

您已在类中声明了您的变量。 如果要使用此变量,则它必须位于成员的上下文中。 例如:

[Test]
public void test_my_index_page()
{
     var result = home.index();
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM