类型或命名空间名称中不存在命名空间 - 尚未命名空间确实存在 [英] Type or namespace name does not exist in the namespace - yet the namespaces do exist

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

问题描述

这是我一直工作在很长一段时间没有任何问题的项目突然开始抛出错误,如

A project that I've been working on for a long time without any problems suddenly started throwing errors such as

The type or namespace name 'xxx' does not exist in the namespace 'yyy' (are you missing an assembly reference)?

在这种情况下,命名空间是所有的核心.NET库,如系统。数据的LINQ IO ,我一直在使用没有任何问题。

In this case, the namespaces were all core .Net libraries such as System.Data, Linq, and IO that I've been using without any problems.

我已经通过所有的的如确保工作区中的所有项目都使用为目标框架设置相同版本的.NET的这个问题

我删除了相关的所有库,并重新加入他们,但问题依然存在。我怀疑他们库,我在解决方案中的其他项目中引用它们本身损坏。

I removed all the libraries in question and re-added them but the problem persisted. I doubt they libraries themselves are corrupted as I reference them in other projects within the solution.

推荐答案

通过我的工作回滚之后TFS我设法制定出什么我做到了创造了这个错误:我已经添加了一个名为系统我的项目文件夹,并把一个类文件中它

After rolling back through my work with TFS I managed to work out what I'd done that had created this error: I'd added a folder called "System" to my project and put a class file in it.

这是一个简单的问题重现:创建一个项目,称为系统添加一个文件夹(它仍然会编译在这一点),然后在其中创建一个cs文件,这时候会出现所有的乐趣错误。

This is an easy issue to reproduce: create a project, add a folder called system to it (it will still compile at this point) and then create a .cs file in it, that's when all the fun errors will occur.

这个问题从导致它是命名空间。系统下创建的文件系统文件夹的名称造成的。

The problem stems from the name of the "System" folder which leads to any files created in it being under the namespace ".System".

我可以理解为什么有所谓的系统的文件夹/命名空间,现在会造成问题,但我认为这将有助于如果Visual Studio中创建文件夹/命名空间时,这样的名字来制止这一问题发出警告发生在首位。我一直的登录与MS的错误,至少有这个记录可能会帮助谁也犯了同样的错误,因为我任何其他人!

I can understand why having a folder / namespace called "System" would cause problems now but I think it would help if Visual Studio warned when creating a folder / namespace of such a name to stop this problem happening in the first place. I've logged a bug with MS, at least having this logged might help any other people who have made the same mistake as me!

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

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