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

前端 未结 6 1581
后悔当初
后悔当初 2021-01-17 11:50

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

6条回答
  •  攒了一身酷
    2021-01-17 12:12

    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.

提交回复
热议问题