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
433 views
in Technique[技术] by (71.8m points)

asp.net mvc 4 - Visual Studio 2013 C# Web Project builds but IDE reports The type or namespace name xxx could not be found error

When opening an MVC4 C# web project in Visual Studio 2013, the IDE reports the error "The type or namespace name '_' could not be found (are you missing a using directive or an assembly reference)", but the project builds and runs without any errors. Furthermore, intellisense does not include the project namespace.

The "missing" reference is to files within the same project. for example; the web project namespace is "webproject.com", and references in a controller files to "webproject.com.models" is underlined in red with the error above.

I have checked the following:

  • All Solution projects are configured to use the same Target Framework(.Net 4)
  • web.config in the Views folder contains the namespace in the system.web.webPages.razor section
  • cleaned and rebuilt solution
  • deleted all bin and obj content
  • deleted .suo and .csproj.user files that were created by VS2010

The only way that I can get rid of these errors being reported in VS2013 is to unload then reload the project.

When opened in Visual Studio 2010 I do not get these problems.

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

I have the same issue.

ALthough the project compiles correctly, the code editor shows an error The type or namespace name '_' could not be found (are you missing a using directive or an assembly reference).

THere is one workaround. Just delete the *.SUO files and re-open the solution. THen for this only Session it works. Unfortunately after closing and reopening the solution the issue is back again. VS 2012 works fine.

Seems to be a bug in VS 2013....


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

...