visual-studio Visual Studio 错误:已添加具有相同键的项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1701740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 11:11:59  来源:igfitidea点击:

Visual Studio Error: An item with the same key has already been added

visual-studiowinformsresources

提问by PaN1C_Showt1Me

When I'm trying to change the default Image of a Control on Windows Formsin Form Designer (no matter where on which control) I get this error:

当我尝试在窗体设计器中更改Windows 窗体上控件的默认图像时(无论在哪个控件上),我收到此错误:

Error message: An item with the same key has already been added

错误消息:已添加具有相同键的项目

I tried to delete and recreate the Resources.resxfile.. I assured that only 1 resx file with these keys exist.. (in fact that's my only resource file) but it still does not work.

我试图删除并重新创建Resources.resx文件..我保证只有 1 个带有这些键的 resx 文件存在..(实际上这是我唯一的资源文件)但它仍然不起作用。

I have som strings in it and some images. That's all.

我有一些字符串和一些图像。就这样。

Any idea?

任何的想法?

回答by User2400

I had this problem too. The solution is to never create a .resx file with the name "Resources.resx" because it conflicts with the "Resources.resx" files that can be automatically created in the project's properties dialog.

我也有这个问题。解决方案是永远不要创建名为“Resources.resx”的 .resx 文件,因为它与可以在项目属性对话框中自动创建的“Resources.resx”文件冲突。

Just right-click and rename the "Resources.resx" and you should be able to change images perfectly.

只需右键单击并重命名“Resources.resx”,您应该能够完美地更改图像。

回答by Kirill Osenkov

If you really want to figure out what is going wrong, you can try and attach a debugger to VS and break while devenv.exe is showing the message box. From the call stack it should be obvious what VS is doing. Here are more details about debugging Visual Studio: http://blogs.msdn.com/kirillosenkov/archive/2008/12/07/how-to-debug-crashes-and-hangs.aspx

如果您真的想弄清楚出了什么问题,可以尝试将调试器附加到 VS 并在 devenv.exe 显示消息框时中断。从调用堆栈来看,VS 正在做什么应该很明显。以下是有关调试 Visual Studio 的更多详细信息:http: //blogs.msdn.com/kirillosenkov/archive/2008/12/07/how-to-debug-crashes-and-hangs.aspx

If you like, you can post the call stack of the Visual Studio main thread here and I can try to investigate what is going on.

如果你愿意,你可以在这里发布 Visual Studio 主线程的调用堆栈,我可以尝试调查发生了什么。

回答by Nikhil Girraj

Was getting this error while adding a project to a solution. None of the above metioned scenarios applied but restarting visual studio fixed this. Silly, yes. Visual studio version - 2015 enterprise.

将项目添加到解决方案时出现此错误。上面提到的场景都没有应用,但重新启动 Visual Studio 解决了这个问题。傻,是的。Visual Studio 版本 - 2015 企业版。

回答by Shomron

I had the same issue. But in my case it was because I had twice the same file listed in my resources folder. Probably a problem after a merge.

我遇到过同样的问题。但就我而言,这是因为我的资源文件夹中列出了两次相同的文件。可能是合并后的问题。