Visual Studio 2013 C# Web 项目生成但 IDE 报告找不到类型或命名空间名称 xxx 错误 [英] Visual Studio 2013 C# Web Project builds but IDE reports The type or namespace name xxx could not be found error

查看:30
本文介绍了Visual Studio 2013 C# Web 项目生成但 IDE 报告找不到类型或命名空间名称 xxx 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Visual Studio 2013 中打开 MVC4 C# web 项目时,IDE 报告错误找不到类型或命名空间名称 '_'(您是否缺少 using 指令或程序集?参考)",但项目构建和运行没有任何错误.此外,intellisense 不包括项目命名空间.

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.

缺失"引用是指同一项目中的文件.例如;Web 项目命名空间为webproject.com",控制器文件中对webproject.com.models"的引用以红色下划线标出,并带有上述错误.

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.

我检查了以下内容:

  • 所有解决方案项目都配置为使用相同的目标框架 (.Net 4)
  • Views 文件夹中的 web.config 包含 system.web.webPages.razor 部分中的命名空间
  • 清理和重建解决方案
  • 删除了所有 bin 和 obj 内容
  • 删除了 VS2010 创建的 .suo 和 .csproj.user 文件

我可以摆脱 VS2013 中报告的这些错误的唯一方法是卸载然后重新加载项目.

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

在 Visual Studio 2010 中打开时,我没有遇到这些问题.

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

推荐答案

我有同样的问题.

虽然项目编译正确,但代码编辑器显示错误找不到类型或命名空间名称_"(您是否缺少 using 指令或程序集引用).

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

有一种解决方法.只需删除 *.SUO 文件并重新打开解决方案.那么对于这唯一的 Session 它有效.不幸的是,在关闭并重新打开解决方案后,问题又回来了.VS 2012 工作正常.

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.

似乎是 VS 2013 中的一个错误....

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

这篇关于Visual Studio 2013 C# Web 项目生成但 IDE 报告找不到类型或命名空间名称 xxx 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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