VS2010“已添加具有相同键的项目”
我最近安装了 Visual Studio 2010,并将旧的 VS2005 解决方案复制并转换为 VS2010
当我编辑此解决方案时,如果我尝试更改控件的 .image 属性,VS2010 会创建一个消息框,告诉我“具有相同键的项目已经已添加”,并且不允许我浏览图像。
我可以为任何其他解决方案添加图像,甚至可以为从 VS2005 移植的其他解决方案添加图像,但这个不行。知道我做错了什么吗?
I recently installed Visual Studio 2010 and copied and converted an old VS2005 solution to 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", and won't let me browse for an image.
I can add images for any other solution, even others ported from VS2005, but not this one. Any idea what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
进入properties/PublishProfiles,打开.pubxml 文件并检查连接字符串是否重复。我遇到了这个问题,删除了所有重复的连接字符串,留下一个,它解决了我的问题。
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.
如果在 SSDT 发布操作期间收到此错误,请检查 Publish.xml 文件中是否有重复的 SqlCmdVariable 条目。
If you get this error during a SSDT Publish action, check you have not duplicated SqlCmdVariable entries in the Publish.xml file.
有关信息:在将 WPF 项目中的图像属性从
Resource
更改为SplashScreen
时,我遇到了同样的问题 - 一旦更改,错误就会出现,直到清理并重建项目为止。即使在清理之前,我也看不到 csproj 文件中的重复项,在 notepad++ 中编辑,所以它让我搜索了一下!For info: I had the same problem when changing an image properties in a WPF project from
Resource
toSplashScreen
- once changed, the error would appear until the project was cleaned and rebuilt. Even before the clean, I could not see the duplication in the csproj file, editing in notepad++, so it had me searching for a bit!万一它可能对某人有帮助。
我在一个项目中遇到了同样的错误,其中大多数文件是从同一解决方案中的另一个项目添加的,但我将这些文件添加为添加为链接,
看起来像添加为链接要求文件名在整个项目中是唯一的。如果您添加的文件“example.cs”已存在于项目的另一个文件夹/命名空间中,您将收到此错误。
确保您使用添加为链接添加的文件具有唯一的名称。
In case, it might help someone.
I got the same error in a project where most of the files I added from another project in same solution but I added those files as Add As Link
It seems like Add As Link requires file name to be unique across whole project. If you add file "example.cs" which is already exist in another folder/namespace of project, you will get this error.
Make sure files you've added using Add As Link have unique names.
通过搜索我解决了这个问题。解决方案是永远不要创建名为“Resources.resx”的 .resx 文件,因为它与可以在项目属性对话框中自动创建的“Resources.resx”文件冲突。
将 Resources.resx 重命名为 Icons.resx 后,我就能够更改解决方案中任何内容的图像属性。
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.
Once I renamed Resources.resx to Icons.resx, I was able to change the image property for anything in the solution.
我有同样的经历,但由于 .csproj 文件中存在重复的图像资源:
可能来自 Merge Gone Wild(tm)。
相同的症状——常规构建正常,重建失败。
删除重复的资源条目以解决问题。
I had the same experience but due to duplicate image resources in the .csproj file:
Probably from a Merge Gone Wild(tm).
Same symptoms--regular build OK, rebuild fails.
Remove the duplicate resource entries to fix the problem.
关于 Visual Studio 2015
我遇到的问题是我无法加载项目或将其重新添加到任何解决方案中。我会得到其他人报告的相同错误,
这听起来过于简单,但是当您收到此错误时,请关闭所有 Visual Studio 实例。打开您遇到问题的解决方案,然后重试。这对我有用。
Regarding 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
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.
运行VS2010,我可以通过重置环境来修复此错误:
Running VS2010, I was able to fix this error by resetting the environment:
*在 vs2015 中,如果您收到“已添加具有相同密钥的项目”,如下图所示,请删除 csproj 文件中的 iis 配置
您的可能会有所不同,但应类似于以下内容
*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
yours could be different but should be similar to following
我刚刚遇到了同样的问题,但我的解决方案中没有任何“Resources.resx”文件(就此而言,我没有任何 *.resx 文件)。我的问题出现是因为我的 .vcxproj 项目文件尝试使用一个文件两次。我为我的 protobuf 文件添加了自定义构建步骤,并将所有 *.proto 文件添加到我的项目中。然而,rouge .proto 文件出现了两次。摆脱重复项解决了问题。
因此,如果您遇到同样的问题并且没有任何 Resources.resx 文件,请尝试查看您的 .vcxproj 文件并确保没有任何其他文件重复。
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.
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.