C# 在“资源”参数中多次指定该项目。“Resources”参数不支持重复项
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14889973/
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
The item was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter
提问by Jitendra Kumar Rajbhar
While compiling my Visual Studio C# project, i am getting the following error:
在编译我的 Visual Studio C# 项目时,我收到以下错误:
The item "obj\Debug\SampleProject.Forms.MDIMain.resources" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
The item "obj\Debug\SampleProject.Forms.MDIMain.resources" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
However i have searched a lot on internet but none of the solution worked for me.
然而,我在互联网上搜索了很多,但没有一个解决方案对我有用。
I tried to delete the form and re-added it into the project, but it doesn't work for me.
我试图删除表单并将其重新添加到项目中,但它对我不起作用。
I only have one resx
file.
我只有一个resx
文件。
I am using VS 2010.
我正在使用 VS 2010。
Also, i tried the following solutions but it not worked for me:
另外,我尝试了以下解决方案,但对我不起作用:
回答by John Kroetch
I had this problem recently, and I think I figured out my particular situation, so maybe it will help you.
我最近遇到了这个问题,我想我已经弄清楚了我的具体情况,所以也许它会对你有所帮助。
I had used the Visual Studio IDE to copy an existing form (let's call it Form1
). I pasted it into the same project (it arrived as Copy of Form1
)
我曾使用 Visual Studio IDE 复制现有表单(我们称之为Form1
)。我将它粘贴到同一个项目中(它作为Copy of Form1
)
I then renamed that new copy to Form2
.
然后我将该新副本重命名为Form2
.
It took me a while, but I eventually found that the IDE had renamed both Form1
and Copy of Form1
to Form2
我花了一段时间,但我最终发现了IDE都改名Form1
,并Copy of Form1
以Form2
The filenames were correct... just the actual classes inside were named.
文件名是正确的……只是里面的实际类被命名了。
I manually renamed the original back to the proper class and voila, it worked.
我手动将原始文件重命名回正确的类,瞧,它起作用了。
回答by Sabri Aziri
I had the same error and In my case, i fixed this problem like the follow.
我有同样的错误,就我而言,我解决了这个问题,如下所示。
Down the highlighted part was another file some_name_not_equal_to_main.resx and after removing it, my program start to run normally.
突出显示的部分是另一个文件 some_name_not_equal_to_main.resx ,删除它后,我的程序开始正常运行。
Hope this helped you.
希望这对你有帮助。
回答by Harpreet Chawla
After renaming the file, rename the class and all the constructors inside the new created file. By default, the name of the file changes but the name of the classes inside them doesn't change. So do the needful.
重命名文件后,重命名新创建的文件中的类和所有构造函数。默认情况下,文件的名称会更改,但其中的类的名称不会更改。做有需要的人。
回答by klinkenbecker
I just had this same problem. Not sure of exact semantics, but it is related to maintaining multiple files as partial of 'Main' form class.
我刚刚遇到了同样的问题。不确定确切的语义,但它与将多个文件维护为“主”表单类的一部分有关。
In my case, the IDE got it into it's head to add form initialization routines to one of the partial class files that wasn't the 'main' form.
在我的情况下,IDE 开始考虑将表单初始化例程添加到不是“主”表单的部分类文件之一。
That created two 'main' forms and the conflict.
这创造了两种“主要”形式和冲突。
Simply finding the added init functions and removing them, along with the associated .resx file, fixed the problem.
只需找到添加的 init 函数并删除它们,连同相关的 .resx 文件,即可解决问题。
回答by sgupta
If you have created a copy of form, go to properties and change the name of the copied form.
如果您创建了表单的副本,请转到属性并更改所复制表单的名称。
In most cases it happens when you create the copy of form. When you create copy of the form, then new form has the same name as of old one. It is not the old form's name is changed.
在大多数情况下,当您创建表单副本时会发生这种情况。当您创建表单的副本时,新表单的名称与旧表单的名称相同。它不是旧表格的名称被更改。
From this example:
从这个例子:
I had used the Visual Studio IDE to copy an existing form (let's call it Form1). I pasted it into the same project (it arrived as Copy of Form1). Now go to "Copy of Form1" []In case you have already renamed then it will be that name] Go to Properties Change Name to Form2 (or whatever class name you want)
我曾使用 Visual Studio IDE 复制现有表单(我们称之为 Form1)。我将它粘贴到同一个项目中(它作为 Form1 的副本到达)。现在转到“Form1的副本”[]如果您已经重命名,那么它将是那个名称]转到属性将名称更改为Form2(或您想要的任何类名)
and it should work.
它应该工作。
Also, remember when you rename the class name, it is possible that references to the class name in the code also get changes. So be cautious of that. I will suggest after changing name, re-compile the code, so that if references are changed then you can revert back to original class name (Form1 in this case). Then you can start using your new class references.
另外,请记住,当您重命名类名时,代码中对类名的引用可能也会发生变化。所以要小心。我会建议在更改名称后重新编译代码,以便如果引用更改,那么您可以恢复到原始类名(在这种情况下为 Form1)。然后您可以开始使用新的类引用。
回答by Marcelo Lujan
Easy!
简单!
Right-click your project and select "Unload Project"
Right-click again and "Edit your_project.csproj"
Search for the duplicate files mentioned in the error message and remove them.
Save and close.
Right-click to choose "Reload Project" view image
右键单击您的项目并选择“卸载项目”
再次右键单击并“编辑 your_project.csproj”
搜索错误消息中提到的重复文件并将其删除。
保存并关闭。
右键单击以选择“重新加载项目”查看图像