How to solve a "duplicate items" error in the "Resources" parameter - c#

While working on my project, I got this error:
The item "..." was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
(Removed the item's name, doesn't matter)
However, I do not know how to solve this. Where do I find this parameter in Visual C# Express?

I guess the item "..." is a form, then:
Remove the "..." form from recent solution (and save somewhere)
Recompile the project
Save the solution
Restart the solution
Add the "..." form
Recompile

Create a backup of both the .cs and .designer.cs file which is giving the error and then delete that file from the project. Rebuild the solution and then copy back both .cs and .designer.cs files. Finally, rebuild the solution again.

I received this error after I copy and paste Form1 (for example) in my project.I rename Copy in Form2, but Form2 had next line in *.cs "public partial class Form1". As i understand after copying class name didn't change. I resolved this problem by adding a new form and copying there controls from my old form. The Old form was deleted.

A slightly simpler way ..
Select the form and then right-click and select "Exclude from Project".
Clean and Recompile project
Select the "Show all files" icon on Solution toolbar to show the excluded form files.
Select the form and then right-click and select "Include in Project" to add it back.
Recompile project
Save All to ensure that project file is saved.
No need to restart Solution or move the form.

This happen when you change name form it duplicate resources file of form.
You open old copy all items and paste to new resource then delete old res file.
Rebuild Solutions.

To fix the issue I browsed to [obj > Debug] and [obj > release] and deleted any files which referenced the word resources. After this, my project built successfully.

Related

Source file '' could not be found

I have some solution already created I need to work with, but I get these:
Warning 1 At least one file is missing the 'RelPath' attribute. SolutionName
Error 2 Source file '' could not be found C:\Users\me\Desktop\someDir\someDir\CSC SolutionName
I use VS Express 2013 for Desktop.
I get this error when I click rebuild solution
Why I get this error and how to fix it?
Create a backup of your project file.
In solution explorer, right click your project and unload it. Then right click again and "Edit project file".
There you can inspect your files. There should be a problem with one of them, like lacking a file name, or something different from the other files.
Remove the attributes regarding that file, save the project, right click, reload project.

Resource.designer.cs NOT regenerating in Mono (Xamarin Studio)

I'm currently developing an app with Mono, I recently updated to Xamarin Studio 4.0.8, and was having problems with the design elements not being added to the solution.
I tried to edit manually the designer.cs, and later on I erased it, hoping the program will regenerate it again, with the layout changes.
I have tried:
Rebuilding it
Cleaning and rebuilding
Erasing the file through the file explorer
And it still doesn't regenerate properly, Xamarin creates the Resource.designer.cs but it's empty, and when compiling it returns this:
Error CS0103: The name 'Resource' doesn't exist in the current context (CS0103)
Help please...
Lots of time having this issue. What i did:
Remove "resources.designer.cs" using Xamarin (secondary button->remove).
Go to command line (finder on Mac/Explorer on Windows) and delete manually the file (be sure you deleted it).
Go to Xamarin, clean->build (this will regenerate the resoruces.designer.cs).
As you remove the file from the project, you have to add it again. secondary button over project-> add Files->select Resources.designer.cs (tipically on /Resources folder).
Make sure the "Build Action" of the Resource.designer.cs file is Compile (sometimes it takes a different build action by default).
Clean and build.
At least it have worked most of the time.
I had this happen a while back. If you right click on your XML file, and click properties. Make sure that the Build Action is set to "AndroidResource"
If I recall correctly that fixed it
This work for me:
Open your .designer.cs file and erase all class content, letting only the class declaration empty.
open .xib file or storyboard that give you trouble with your .cs file.
update Identify>Class property of the view that use that .designer.cs class removing, unfocus, focus and setting again the property value.
save
rebuild

not able to change name after copying a form

I'm trying to copy and past a form within a project using Visual Studio.
I've managed to copy and past the form (right clicking in the Solution explorer > Copy; Right click again paste) I can change the name of the new form in the Solution explorer. But when I select the form [Design] I can't change the name property without changing the name property in the original form. Somehow the two are linked. What am I doing wrong?
I hope this all makes sense.
Exclude all files of that form from project and then include again.
You can perform the include steps after reopen the project.

Duplicate items are not supported by the "Resources" parameter

The item obj\Debug\BookStore.MainForm.resources was specified more than once in the Resources parameter. Duplicate items are not supported by the Resources parameter.
How do I fix this?
This error happened when you copy and paste a form in the 'Solution Explorer' pane. Then you change name of one forms. Visual studio give the same name for both and then, when you rename form, Visual Studio do some refactoring for you and rename Designer class for both forms (not only for new).
You can fix this two ways:
Close Microsoft Visual Studio, then browse to your project folder from external program (ex. Total Commander). Into the folder where both forms are defined you can see your form's .cs and .Designer.cs file. Open the .cs and .Designer.cs files for your form in a text editor. Find and replace every instance of the original form name with new name. And if you rename already rename some resources, check file for original form also (if they are only original form name but not anything for new form name). Then save all files, start Microsoft Visual Studio and rebuild your project.
You can try chcek and rename declaration for each occurance of original form name in new .cs and .Designer.cs files but try disable refactoring. If you already renamed new form, in .Designer.cs for old form you maybe see this:
namespace YourProjectNamespace
{
partial class NewFormName
{ .. }
You must rename NewFormName to OldFormName and when Visual Studio offer you a refactoring menu (small reg rectangle before last letter of renamed object) do not make anything.
This happened to me when I created a partial form class. When I unintentionally viewed it in Design mode it created a localized resx file for the new partial form. I deleted that resx file and that resolved it.
you cant add to the resources file 2 items with the same name/key. it has to be unique
Check the *.resx files in your project as #Royi Namir described.
In case you have already done that: check your .resx.designer files. Some programs "optimize" the designer files.
The designer files are just plain xml. If they are not in sync with the corresponding xml you'll get an exception as described.
I have same problem, and I able to resolve it by these steps:
Right-Click to your form name example: MainForm
To Review: Select Find All References now you will see the list of form of possible conflicts
To Fix: Select Refactor -> Rename -
Select Preview reference changes
Rename it Differently
Un-checked for the Conflict Form/class

What could cause Visual Studio / C# error MSB3105: Duplicate resources

While working on an existing project I suddenly got the following error when trying to compile the solution:
error MSB3105: The item "[filename]" was specified more than once in the "Resources" parameter. Duplicate items are not supported by the "Resources" parameter.
Now, as far as I'm aware, I did not make any change to the project that affects the resources. Also I have checked each and every file within the project, but there is no duplicate reference anywhere to this file.
Now I already found some forum entries regarding this error:
1) Open the .csproj file and remove the duplicate reference. [Tried this, but I cannot find any duplicates in it]
2) In a 'partial class' project, move everything to a single class. [ Could try this, but the project has been split up into partial classes since the start, and I do not want to change this just because of the error ]
So what else could cause this ?
Did you try showing all files in the Solution Explorer? You could have a duplicate .rsx file somewhere in there.
I found the answer in .NET forum posting by Roy Green, and Theresa was right after all, though I did not recognize it.
If you have your main form class split up into partial classes, the partial sections end up in the solution explorer as separate items. And if you double click on them they show up in the designer mode as a normal form. But if you (accidentally) drop a control on these forms, Visual Studio creates a new .resx file and a InitializeComponent routine for it. But since this form is actually just part of the Main Form class it leads to the 'duplicate resources' error. And there is no other solution but to remove the InitializeComponent routine and delete the .resx file by hand.
Be sure that under yourForm.cs no duplicate resources are defined (.resx). If you renamed your Form, remove the old resource because the new one during compile will be created with the new name.
I just made the same mistake. Delete the mainform.designer.vb, then I restored it again from the recycle bin, and found this error message when compiling.
I try to search on google and someone suggested to check on .vbproj. Did that and found a duplicate on some line.
I had this as well, in VB. There is the "real form" file frmMain, and then I had created new class files and modified them to be Partial Public Class frmMain. For example, I have an ImportFromExcel.vb Partial Class file (I didn't want to clutter up the frmMain.vb with the rather complicated Excel import code.)
Everything worked fine until I decided I wanted to use an OpenFileDialog in the Sub ImportFromExcel. I dragged the OFD from the toolbox over to the Designer view of the ImportFromExcel file. (I have no idea why this view exists, if you can't do anything with it!) But at any rate... dragging the OFD to the Partial Class Designer created an ImportFromExcel.resx file. The drag/drop operation also created an InitializeComponent sub in ImportFromExcel, which is redundant and shows an error -- easily corrected with a little editing.
Ultimately, I chose to not use the dragged resource, but localized the code in the ImportFromExcel.vb file.
All you really have to do is right-click the ImportFromExcel.resx file, and choose Delete. Everything else seems to "fix itself", and it builds fine now.
In my case, this problem happened because a file had the same name but not the same case in the GIT repository.
For example MyFile.cs and myFile.cs.
If you do a checkout on windows, one of the files is overwritten by the other (no message, no warning). So, it is compiling, and we don't notice anything. But if you try to compile on Linux (with .NET Core) both files are present, and there is this error at compile time.

Categories