添加引用对话框中路径包含 # 时出现问题
我刚开始使用 Microsoft 开发工具,但过去几周一直在使用 Visual Studio 2010、.NET 4 和 C#。昨天我在创建一个新项目时遇到了一个问题,就像我从一开始就成功地做到了这一点一样:在解决方案资源管理器中右键单击该项目→添加引用,曾经会弹出这个对话框:
旧对话框 http://img514.imageshack.us/img514/8978/oldaddreferencedialogue .jpg
几周没有新项目后,我昨天去创建一个项目并得到了一个新的“添加引用”对话框。尝试添加我已经添加了几周的相同 dll 导致了此处出现的错误:
新对话框 http://img692.imageshack.us/img692/2074/newaddreferencedialogue.png
因此,经过痛苦的一天尝试确定原因后,在我看来,它与新对话框有关被我参考路径中的 # 窒息了。当我删除 # 时,一切都按预期进行。考虑到微软有两种名称中带有 # 的 .NET 语言,我很惊讶这个问题一直困扰着人们(多年来我一直听说过这个问题,但直到最近我才对微软工具做过太多工作,所以我当然这么做了不记得了。)
来自 Visual Studio 新手的问题:
在路径中不使用 # 是常识吗?
当我的同事使用相同的 VS 版本,仍然有可以很好地处理路径中的 # 的旧对话框时,我如何/为什么得到这个新的“添加引用”对话框?
I am new to using Microsoft development tools but have been using Visual Studio 2010, .NET 4 and C# for the past few weeks. I ran into a problem yesterday creating a new project the same way I have been doing it successfully from the start: right-click on the project in the Solution Explorer → Add Reference, which used to bring up this dialog:
Old Dialog Box http://img514.imageshack.us/img514/8978/oldaddreferencedialogue.jpg
After a couple of weeks of no new projects I went to create one yesterday and got a new Add Reference dialog. And trying to add the same dll I have been adding for weeks now resulted in the error seen here:
New Dialog http://img692.imageshack.us/img692/2074/newaddreferencedialogue.png
So, after a painful day trying to determine the cause, it looks to me like it has something to do with the new dialog choking on the # I had in my reference path. When I removed the # everything works as expected. Considering Microsoft has two .NET languages with # in the name, I am surprised that this issue keeps biting people (I have heard of this problem over the years, but I have never done much with Microsoft tools until recently, so of course I did not recall it.)
Questions from a Visual Studio newbie:
Is it common knowledge to not use # in paths?
How/why did I get this new Add Reference dialog when my colleagues, using the same VS version, still have the old dialog that handles # in paths just fine?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的观点是,如果你在路径中使用奇怪的字符,你就会得到你应得的。 :)
我知道除了 Pro Power Tools 扩展中可能存在的问题之外,核心 VS 产品中的路径中还存在有关“#”字符的错误。往返 URI 和文件名的代码数量惊人,并且在通过
System.Uri
进行往返时,“#”字符(及其后的所有字符)都会被丢弃。一般来说,我认为可以安全地假设在创建文件名/路径时,将有 10,000 个不同质量的工具尝试解析文件名,并且这些工具的一个(大)子集将在“奇怪”字符上失败。尽可能避免使用奇怪的字符。你必须选择你的战斗。在理想的情况下,工具对于此类问题应该是稳健的。在现实世界中,最好将路径命名为“CSharp”而不是“C#”,然后继续处理生活中更重要的事情。
My opinion is that if you use weird characters in paths, you get what you deserve. :)
I know there are bugs about '#' character in paths in the core VS product, in addition to whatever may be in the Pro Power Tools extension. There is a surprising amount of code that goes to/from URIs and filenames, and '#' characters (and everything thereafter) get dropped when roundtripping via a
System.Uri
.In general, I think it's safe to assume that when creating filenames/paths, there will be 10,000 tools of various quality trying to parse the filenames, and a (large) subset of those tools will fail on 'weird' characters. Just avoid weird characters whenever possible. You gotta choose your battles. In an ideal world, tools would be robust to these kinds of issues. In the real world, it's better to name a path "CSharp" rather than "C#" and move on with more important things in life.
第二个对话框来自 VS2010 生产力工具pack - 我自己没有使用过它,所以不知道它有什么问题。您最近安装过这个吗?
The second dialog is the one from the VS2010 productivity power tools pack - I havent used it myself so dont know of any problems with it. Have you recently installed this?