visual-studio VS2010“已添加具有相同键的项目”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3003914/
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
VS2010 "An item with the same key has already been added"
提问by User2400
I recently installed Visual Studio 2010 and copied and converted an old VS2005 solution to VS2010
我最近安装了 Visual Studio 2010 并将旧的 VS2005 解决方案复制并转换为 VS2010
When I edit this solution, if I try to change a control's .image property, VS2010 creates a message box telling me that "An item with the same key has already been added" (screenshot below), and won't let me browse for an image.
当我编辑此解决方案时,如果我尝试更改控件的 .image 属性,VS2010 会创建一个消息框,告诉我“已添加具有相同键的项目”(下面的屏幕截图),并且不会让我浏览一个图像。
I can add images for any other solution, even others ported from VS2005, but not this one. Any idea what I'm doing wrong?
我可以为任何其他解决方案添加图像,甚至是从 VS2005 移植的其他解决方案,但不是这个。知道我做错了什么吗?
已添加具有相同键的项目。http://img121.imageshack.us/img121/3592/errorsy.jpg
采纳答案by User2400
I worked this out thanks to a search. 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”文件冲突。
Once I renamed Resources.resx to Icons.resx, I was able to change the image property for anything in the solution.
一旦我将 Resources.resx 重命名为 Icons.resx,我就能够更改解决方案中任何内容的图像属性。
回答by methylamine
I had the same experience but due to duplicate image resources in the .csproj file:
我有同样的经历,但由于 .csproj 文件中的图像资源重复:
<Resource Include="Images\trigger-ModuleSelector1.png" />
<Resource Include="Images\trigger-ModuleSelector2.png" />
<Resource Include="Images\document.png" />
<Resource Include="Images\folder.png" />
<Resource Include="Images\trigger-ModuleSelector1.png" />
<Resource Include="Images\trigger-ModuleSelector2.png" />
Probably from a Merge Gone Wild(tm).
可能来自 Merge Gone Wild(tm)。
Same symptoms--regular build OK, rebuild fails. Remove the duplicate resource entries to fix the problem.
相同的症状——常规构建正常,重建失败。删除重复的资源条目以解决问题。
回答by dyslexicanaboko
Regarding Visual Studio 2015
关于 Visual Studio 2015
The problem I was having was I could not load a project or re-add it to ANY solution. I would get the same error reported by others which is
我遇到的问题是我无法加载项目或将其重新添加到任何解决方案中。我会得到其他人报告的相同错误,即
Project '...' could not be opened because the Visual C# compiler could not
be created. An item with the same key has already been added.
This is going to sound overly simplistic, but when you get this error close ALL Visual Studio instances. Open the solution you were having trouble with and try again. This worked for me.
这听起来过于简单,但是当您收到此错误时,请关闭所有 Visual Studio 实例。打开您遇到问题的解决方案,然后重试。这对我有用。
回答by Joe Phillips
Running VS2010, I was able to fix this error by resetting the environment:
运行 VS2010,我能够通过重置环境来修复此错误:
Tools > Import and Export Settings > Reset all settings
回答by Azadeh Khojandi
*in vs2015 if you get "An item with the same key has already been added" like image bellowm delete iis configuration in your csproj file
*在 vs2015 中,如果您收到“已添加具有相同密钥的项目”,如图像波纹管,请删除您的 csproj 文件中的 iis 配置
yours could be different but should be similar to following
你的可能不同,但应该类似于以下内容
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>32049</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:32049</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
回答by PontiusTheBarbarian
go inside properties/PublishProfiles, open the .pubxml file and check to see if your connection strings have been repeated. I had this issue, removed all the duplicate connection strings to leave one remaining and it solved my issue.
进入 properties/PublishProfiles,打开 .pubxml 文件并检查您的连接字符串是否重复。我遇到了这个问题,删除了所有重复的连接字符串以留下一个,它解决了我的问题。
回答by Cornstalks
I just had this same problem, but I didn't have any "Resources.resx" file in my solution (I didn't have any *.resx files, for that matter). My problem came because my .vcxproj project file was trying to use a file twice. I had added a custom build step for my protobuf files and added all my *.proto files to my project. However, a rouge .proto file appeared twice. Getting rid of the duplicate solved the problem.
我刚刚遇到了同样的问题,但我的解决方案中没有任何“Resources.resx”文件(就此而言,我没有任何 *.resx 文件)。我的问题是因为我的 .vcxproj 项目文件试图使用一个文件两次。我为我的 protobuf 文件添加了一个自定义构建步骤,并将我所有的 *.proto 文件添加到我的项目中。但是,rouge .proto 文件出现了两次。摆脱重复解决了这个问题。
So if you're having the same problem and you don't have any Resources.resx file, try looking at your .vcxproj file and making sure there aren't any other files that are getting duplicated.
因此,如果您遇到同样的问题并且没有任何 Resources.resx 文件,请尝试查看您的 .vcxproj 文件并确保没有任何其他文件被复制。
回答by Wayne
If you get this error during a SSDT Publish action, check you have not duplicated SqlCmdVariable entries in the Publish.xml file.
如果您在 SSDT 发布操作期间收到此错误,请检查您是否在 Publish.xml 文件中复制了 SqlCmdVariable 条目。


