Search code examples
c#asp.net-mvctfsasp.net-mvc-5

The type or namespace name 'Models' does not exist in the namespace 'PartyInvites'


Using VS2013 Pro, TFS 2013 Express

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.

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);
        }
    }
}

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.

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.

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) Does anyone know how to solve this problem so I don't have to delete the SUO file all the time?

EDIT 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; }
    }
}

EDIT 2

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.


Solution

  • 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.