The item was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter
Asked Answered
P

7

33

While compiling my Visual Studio C# project, i am getting the following error:

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.

I am using VS 2010.

Also, i tried the following solutions but it not worked for me:

  1. https://mcmap.net/q/452952/-how-to-solve-a-quot-duplicate-items-quot-error-in-the-quot-resources-quot-parameter
  2. https://stackoverflow.com/a/10066009
Puerperium answered 15/2, 2013 at 7:24 Comment(0)
J
37

Easy!

  1. Right-click your project and select "Unload Project"

  2. Right-click again and "Edit your_project.csproj"

  3. Search for the duplicate files mentioned in the error message and remove them.

  4. Save and close.

  5. Right-click to choose "Reload Project" view image

Junior answered 31/5, 2016 at 17:38 Comment(2)
This right here. The issue for me was the .projitems file for a shared solution referenced the same file twice. Just look in all your proj (.csproj, .vbproj, etc.) files for whatever file name the error message is saying is duplicated. Then just remove all but one line that references it.Cynthia
Turns out the .csproj already had an item to include all .cs files, so when VS 2017 added the new classes, it created items that were not needed.Blender
H
18

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)

I then renamed that new copy to Form2.

It took me a while, but I eventually found that the IDE had renamed both Form1 and Copy of Form1 to 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.

Henna answered 19/6, 2013 at 21:39 Comment(3)
Also depends on the type of file, but I ran into this while working with XAML files - and I suppose it can apply to other files that require VS to use designers normally. Open the files you've copied by looking at the code, and ensure all of the names are straightened out there. In my case, VS didn't know any better to rename some of those variables in the XML.Cowden
This was exactly my problem. I also copy/pasted a form into the same project and the rename didn't quite rename everything as it should. I also had to rename the class name in the Form.Designer.cs file for the newly pasted form.Elviaelvie
Had this with SharePoint Workflows. I'd copied one and renamed it but inside the Workflow.xaml (3 spots) and the SharePointProjectItem.spdata (2 spots +1 for every association) files the rename wasn't complete. I manually updated these and everything built correctly.Earpiercing
R
4

I had the same error and In my case, i fixed this problem like the follow.

enter image description here

Down the highlighted part was another file some_name_not_equal_to_main.resx and after removing it, my program start to run normally.

Hope this helped you.

Riding answered 22/6, 2013 at 16:53 Comment(0)
T
1

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.

Thrall answered 26/2, 2014 at 7:23 Comment(0)
F
1

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.

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.

Flaunch answered 24/3, 2014 at 17:16 Comment(0)
G
0

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)

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.

Glaciate answered 5/3, 2015 at 2:7 Comment(0)
M
0

Sometimes, partial class with the same name of another class would create this problem. Try to find out is there any two classes with the same class name. Remove/rename one of this, then your problem would be solved.

Menstruate answered 6/4, 2021 at 14:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.