命名空间“PartyInvites"中不存在类型或命名空间名称“Models" [英] The type or namespace name 'Models' does not exist in the namespace 'PartyInvites'

查看:22
本文介绍了命名空间“PartyInvites"中不存在类型或命名空间名称“Models"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 VS2013 Pro、TFS 2013 Express

Using VS2013 Pro, TFS 2013 Express

我目前正在做 asp.net mvc 5 一书中的教程,一切都很好.昨天我在本地机器上安装了 TFS 2013 Express,将项目复制到 TFS 文件夹并将项目添加到源代码管理.

I'm currently doing a tutorial from the book asp.net mvc 5 and everything was fine. yesterday I installed TFS 2013 Express onto my local machine, copied the project over to the TFS folder and added the project to source control.

自从这样做以来,我现在遇到了类似主题的错误.在这种情况下,控制器只有一个 using:

Since doing that I'm now getting errors like the subject. In this case the controller simply has a using:

using System.Web;
using System.Web.Mvc;
using PartyInvites.**Models**;

namespace PartyInvites.Controllers
{
    public class HomeController : Controller
    {
        // GET: Home
        //public ActionResult Index()
        //{
        //  return View();
        //}

        public ViewResult Index()
        {
            int hour = DateTime.Now.Hour;
            ViewBag.Greeting = hour < 12 ? "Good Morning" : "Good Afternoon";
            return View();
        }

        [HttpGet]
        public ViewResult RsvpForm()
        {
            return View();
        }

        [HttpPost]
        public ViewResult RsvpForm(**GuestResponse** guestResponse)
        {
            //todo: Email response to the party organizer
            return View("Thanks", guestResponse);
        }
    }
}

在 HttpPost 中,对象GuestResponse"是红线所在的位置,但此对象位于模型命名空间等中.EDIT 红线也在模型"一词上顶部的 using 语句.

in the HttpPost, the object "GuestResponse" is where the red line is, but this object IS in the models namespace etc. EDIT The red line is also on the word "Models" in the using statement at the top.

现在我注意到,如果我从解决方案文件夹中删除 SUO 文件并打开解决方案,错误就会消失,但是一旦我保存解决方案并重新打开它,错误就会回来.我还注意到我知道的其他几个项目也存在同样的问题.

Now I've noticed that if I delete the SUO file from the solution folder and open the solution the error goes away, but as soon as I save the solution and reopen it the error comes back. I've also notice this same problem is a couple of other projects I know work.

另外 - 当我构建解决方案时,他们构建的没有错误,但红线仍然存在.

Also - When I build the solutions they build with no errors, but the red lines are still there.

我认为问题出在 SUO 文件和 TFS 上,因为该解决方案在 None TFS 版本中非常有效,但我找不到 SUO 和 TFS 的解决方案.我是 PC 的唯一用户,拥有完整的管理员权限.

I think the problem is with the SUO file and TFS as the solution works absolutely fine in the None TFS version, but I can't find a solution to SUO and TFS. I am the sole user of the PC and have full admin rights.

Q) 有没有人知道如何解决这个问题,这样我就不用一直删除 SUO 文件了?

Q) Does anyone know how to solve this problem so I don't have to delete the SUO file all the time?

编辑 1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace PartyInvites.Models
{
    public class GuestResponse
    {
        public string Name { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public bool? WillAttend { get; set; }
    }
}

编辑 2

我现在尝试 FILE>SourceControl>Change source control to Unbind from source control,它现在按预期工作......但它现在不在源代码管理中.我认为这个问题现在与 TFS 相关.- 更新.重新绑定回TFS后,问题又回来了.

I've now tried to FILE>SourceControl>Change source control to Unbind from source control, and it's now working as expected... but it's now not in source control. I think this issue is now down to TFS related. -- Update. After rebinding it back to TFS, the problem returns.

推荐答案

我终于找到了一个有效的答案.是 VS2013 中的一个错误导致了问题,下面是答案链接.

I've finally found an answer that worked. It's a bug in VS2013 that is causing the problem, below is the link with the answer.

但简而言之,关闭在解决方案或项目打开时获取所有内容"可以解决问题,虽然不是完整的修复,但对我来说它解决了问题

but in short, turning off the "Get everything when a solution or project is open" solves the problem, though not a complete fix, but for me it solved the problem

http://connect.microsoft.com/VisualStudio/feedback/details/760443/visual-studio-2012-ide-loses-intellisense-and-reference-resolution

希望这对其他人有帮助.

Hope this helps others.

这篇关于命名空间“PartyInvites"中不存在类型或命名空间名称“Models"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆