Visual Studio 2010 突然看不到命名空间? [英] Visual Studio 2010 suddenly can't see namespace?

查看:45
本文介绍了Visual Studio 2010 突然看不到命名空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 C# WinForms 解决方案有两个项目.一个 DLL 是我正在处理的主要项目,还有一个我称之为沙箱"的可执行 WinForms,以便我可以轻松地一次性编译/运行/调试 DLL.

My C# WinForms solution has two projects. A DLL which is the main project I'm working on, and an executable WinForms I call "Sandbox" so that I can compile/run/debug the DLL easily in one go.

我正在为这两个项目使用 .Net 4.0.

I'm working in .Net 4.0 for both projects.

一切正常,直到我添加了一些看似无害的代码,并在 DLL 中添加了对 System.Web 的引用.现在我的 Sandbox 项目看不到 DLL 项目的命名空间.我没有更改任何我认为应该影响此的内容.

Everything was working fine until I added some seemingly innocent code, and a reference to System.Web in the DLL. Now my Sandbox project can't see the namespace of the DLL project. I didn't change anything which I believe should have affected this.

如果我从 Sandbox 引用中删除对 DLL 的项目引用并重新添加它,那么红色下划线将全部消失,并且我的所有类等的颜色编码都会恢复;但是一旦我尝试构建解决方案,整个事情就会再次崩溃.

If I delete the project reference to the DLL from the Sandbox references and re-add it, then the red underlines all disappear and the colour coding comes back for all my classes etc; but as as soon as I try to build the solution, the whole thing falls apart again.

当我右键单击 Sandbox 引用中的 DLL 项目并在对象浏览器中查看时,我可以看到命名空间和其中的所有内容.

When I right-click the DLL project in the Sandbox's references and view in object browser, I can see the namespace and all the stuff in there.

我觉得这可能是某种错误?

I have a feeling this might be some sort of bug?

这是某种 VS2010 错误吗?几个月前我遇到了同样的问题,当时我只能通过创建一个全新的项目并重新导入我的文件来解决它.然而,这一次,我有大量的文件,并且只会作为最后的手段!

Is this some sort of VS2010 bug? I had this same issue a few months ago and I could only fix it at the time by making a whole new project and re-importing my files. This time, however, I have a bajillion files and will only do that as a last resort!

在惊慌失措地完成并撤消所有更改后,试图找出导致问题的原因,似乎是这一行:

After panickedly going through and undoing all my changes, trying to find what caused the problems, it seems to be this line:

string url = "http://maps.google.com?q=" + HttpUtility.UrlEncode(address);

如果我注释掉这一行,则不会出现命名空间错误并且项目构建良好.不过我看不出这条线有什么问题.

If I comment out this line, then I get no namespace errors and the project builds fine. I can't see anything wrong with this line though.

推荐答案

我已经准备好宣布这是 VS2010 中的一个错误,这已经让太多程序员感到厌烦了.修复很简单:项目 + 属性,应用程序选项卡,将目标框架更改为.NET Framework 4",而不是默认选择的客户端配置文件.

I'm ready to declare this a bug in VS2010, this has bitten way too many programmers already. The fix is easy: Project + Properties, Application tab, change Target Framework to ".NET Framework 4" instead of the Client Profile that is selected by default.

System.Web 不包含在客户端配置文件中.一开始就使用这个选项是很愚蠢的,客户端配置文件仅比 .NET 4.0 的完整版本小 15%.默认情况下选择它甚至更愚蠢.但我离题了.

System.Web is not included in the client profile. Having this option in the first place is quite silly, the client profile is only 15% smaller than the full version of .NET 4.0. Having it selected by default is even sillier. But I digress.

更新:幸运的是,这一切都在 VS2012 中得到了修复.这不再使客户端配置文件成为新项目的默认配置.并且客户端配置文件在 .NET 4.5 中完全弃用了,很好.

UPDATE: mercifully this all got fixed in VS2012. Which no longer makes the client profile the default for a new project. And the client profile got retired completely in .NET 4.5, good riddance.

这篇关于Visual Studio 2010 突然看不到命名空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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