Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ?

like image 641
Cees Meijer Avatar asked Nov 24 '08 09:11

Cees Meijer


People also ask

Why C is not working in VS code?

Go to the menu Code > Preferences > Settings. In the User tab on the left panel, expand the Extensions section. Find and select Run Code Configuration. Find and check the box Run in Terminal.

Can Microsoft Visual C be uninstalled?

Uninstall Microsoft Visual C++ Type in Control Panel and click OK. Select Uninstall a Program. On the list of programs, select the version of Microsoft Visual C++ for your version of QuickBooks. Click Uninstall and follow the onscreen instructions to uninstall the program.


2 Answers

Did you try showing all files in the Solution Explorer? You could have a duplicate .rsx file somewhere in there.

like image 156
Theresa Avatar answered Oct 12 '22 12:10

Theresa


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.

like image 30
Cees Meijer Avatar answered Oct 12 '22 13:10

Cees Meijer