Reputation: 993
Recently I created new Form
called WorkersScreen
. When I try to run the project I got this error:
Error 1 Two output file names resolved to the same output path: "obj\x86\Debug\DryWash.WorkersScreen.resources"
What does it mean and how does one resolve it?
Upvotes: 86
Views: 118717
Reputation: 21
This problem is with vs 2017 and I uninstalled it installed vs 2022 and there is not any problem like that indeed my project was ok and vs 2017 had problem.
Upvotes: 0
Reputation: 93
It also occurs when you add partial form class of an existing class (usally main application class) in windows forms app and create a form for it (e.g. by double-clicking accidentally). In this case, simply delete second class'es .resx file and build again.
Upvotes: 4
Reputation: 191
from the link: https://learn.microsoft.com/en-us/visualstudio/msbuild/errors/msb3577?view=vs-2022
<EmbeddedResource Include="MyResources.resx">
<ManifestResourceName>CustomName</ManifestResourceName>
</EmbeddedResource>
open project file and ensure that the value given for CustomName is different for each generated resource file.
Upvotes: 0
Reputation: 1174
I had the same issue in Visual Studio 2022 with a WinForms application in .NET 6.
In this case, I had added a partial class in it's own .CS
file to handle custom setup outside of the Designer
-generated InitializeComponent
.
The next time that I opened the file, Visual Studio 2022 tried to open this in the WinForm Designer. This added a redundant .resx
file to the project.
Delete the newly added .resx
to correct the error.
Upvotes: 1
Reputation: 669
As @WimOmbelets stated in his 2013's answer, copying a Form is a very sure way to reproduce this annoying error, at least in VS 2017, 2019 and 2022.
As Vince De Giorgio said in his 2019's answer, I too didn't have duplicate .resx or .cs files and I didn't have duplicate ...EmbeddedResource Include= .../> tags in .csproj.
Deleting .resx files (icons gone, obvious) for both involved forms, clean the solution and then restart VS is a poor man's way to solve, because every time I add again an icon or another resource, same annoying error. It is still worse: to recover, I had to Git stash all modifications; if I revert manually all changes, to the point that Git does not recognize any changes, the error continues (!!!) even after cleaning, restarting VS and rebuilding.
To fix the problem in VS 2019 and 2022:
Every time that I want to copy a form, I:
Never more had this problem.
Upvotes: 1
Reputation: 131
I had this problem today.
Some how the Form.Designer had an extension of .resx, for my solution it was TestForm.Designer.resx. There was already a TestForm.resx. I cleaned the solution, closed down VS, deleted the TestForm.Designer.resx file, and then restarted VS. I still had the error.
I then closed down VS and opened the .proj file using NotePad++ and found that the TestForm.Designer.resx was still referenced. I deleted the embedded resource.
<EmbeddedResource Include="TestForm.Designer.resx">
<DependentUpon>TestForm.Designer.vb</DependentUpon>
</EmbeddedResource>
Then I opened VS and built....It work's again!
Upvotes: 1
Reputation: 2988
Find Duplicates by Editing Project File
Note the name of the .resx failure.
Unload the project first by right clicking on your project then click Unload Project
.
It will show you some code, look (or Search
within the file for the resx in step 1) for the duplicate values which in my case is look like this
<EmbeddedResource Include="frmTerminalSerial.resx">
<DependentUpon>frmTerminalSerial.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
Notice this portion, it is a duplicate!
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
Delete one of them so it will look like this
<EmbeddedResource Include="frmTerminalSerial.resx">
<DependentUpon>frmTerminalSerial.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmVisual.resx">
<DependentUpon>frmVisual.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="My Project\Resources.resx">
<Generator>VbMyResourcesResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.vb</LastGenOutput>
<CustomToolNamespace>My.Resources</CustomToolNamespace>
<SubType>Designer</SubType>
</EmbeddedResource>
Save it, right click to your project then click reload project. You are done!
Upvotes: 55
Reputation: 2163
In my case I had to to open the .csproj
in Note++ and looked for .resx
files in EmbeddedResource
tags I found some strange .resx
with strange language suffix example.aa.resx
other files were normal files either with no language suffix or with *.ar suffix, I deleted the creepy embedded resource tag and that fixed the issue for me.
Upvotes: 1
Reputation: 126
I just got this issue using VS 2019 community edition.
I didn't have duplicate .resx files. I didn't have duplicate .cs files. I couldn't find the solution online.
To fix the problem, I cleaned the solution and then restarted VS. Not sure why, but it worked. Hope this helps.
Upvotes: 4
Reputation: 1382
I had the same issue, what I did was delete my migration files (via the studio), after I updated the database.
Upvotes: 0
Reputation: 31
Make sure you don't have two .resx
files. See in your project under YourServiceName.cs
. Works for me.
Upvotes: 2
Reputation: 1
For me the issue was copying and pasting a .aspx, and not renaming the code behind class files to match the name for the copied aspx file. Changing the code behind and designer class names worked.
Upvotes: 0
Reputation: 1628
Normally, if you create a migration like this
Add-Migration "UpdateProducts"
Visual Studio will create a migration with a class name like UpdateProducts. If you add a new migration later using the same migration name, it will generate a migration with a class name like UpdateProducts1., automatically adding an incremented digit to the end as a suffix. Every time you generate a new migration, the number goes up by one.
In our case, for some reason, VS got confused, and started generating subsequent migrations with the same class name as existing migration, so that that there were two auto generated migrations with the same name.
Simply changing the class name of the new migration clears the problem.
Upvotes: 8
Reputation: 18066
I got this problem when I accidentally generated a migration with the same name as a business object. The solution is to delete the migration and then create a new one with a different name.
Upvotes: 1
Reputation: 6021
Search in all project the class reported in error list, like in this question case DryWash.WorkersScreen
it could be repeated in another file with different file name but inside same class name.
Upvotes: 1
Reputation: 298
I had the issue and it was caused because I had a partial class of a custom control.
I had accidentally created a .resx file for the partial
I think I did this by hitting shift F7 on the partial class and producing the empty designer form.
Removing the .resx file on the partial class resolved it for me. I was using version control and it was showing that it was a new file.
Hope this helps
Upvotes: 6
Reputation: 178
If this problem appeared while you were working with EntityFramework and was trying to Add-Migration
, the solution is simple: delete Migrations
folder (in the Solution Explorer) and execute Enable-Migrations
. Backup migrations if you need.
Upvotes: 0
Reputation: 5683
I had the same issue when I renamed one of my Form
classes using Ctrl + R + R
which VS provides to rename things by default.
Then I somewhat got two classes with the same class name on 2 different files (*.cs).
class Bar { ... } // From Bar.cs
class Bar { ... } // This should've been Foo, from Foo.cs
The two Bar
indicating the same resource file that one of them shouldn't.
It's a trivial issue but sometimes could be hard to find the cause because looking at cs files just can't say which one is what you should look for.
Upvotes: -2
Reputation: 763
In my option, help delete one *.resx for every form where the error raised
Detail INFO
In our project we have 6 *.resx for every form for localization (DE,GB,SK,RU,SRB) and if i delete (from VS) FormName.sr-Latn-CS.resx than the error disappeared. If i try deleted FormName.en-GB.resx it did not help. Error disappeared just for delete sr-Latn-CS.resx (maybe a designer can not solved two - ). I first saw this error when I migrated project from VS 2010 Win 7 to VS2010 Win 10.
Upvotes: 0
Reputation: 39
In my case, the issue was caused by an EmbeddedResource tag for a designer.resx file that somehow got added to the .csproj file.
Specifically, the following:
<EmbeddedResource Include="Forms\frmMenu.designer.resx">
<DependentUpon>frmMenu.designer.cs</DependentUpon>
</EmbeddedResource>
Upvotes: 1
Reputation: 23052
This happened to me when I run Add Migration
command and gave same name as my project name as migration class. I removed all migration classes and added new one, solution build again.
Upvotes: 0
Reputation: 137
This happened to me when I copied a form to reuse most of the functionality and then renamed the form. I went to the directory referenced, found that there was in fact only one file, copied the file in question, renamed it to reference the name of my new form, and then pasted the new file back in the directory.
I don't think this is a good practice (I'm new to C#) but it did work, instead of having to recreate everything. I also needed to update the form name in a few places throughout the solution, surprising in the original form as well as in the new form.
Copying forms does not seem like a good idea.
Upvotes: 1
Reputation: 91
I thought that I would post on at least one random forum after encountering this error in hopes of easing someone elses problems. I searched many google sites and none had my exact problem. My cause was similar, but different in some ways.
I actually had a partial class spread across multiple files. this class was a form class. This was successful in itself and didn't cause a problem. However, this caused the new class to keep its unique file name while maintaining a split 'class Form' code. It was most likely not kosher practice, but none the less it happened at the time. It seemed like a good alternative to get a lot of cluttered code out of the way. Needless to say, next time I will just use regions or some other alternative.
The error then occured when I tried to take the code from the 2nd file and copy/paste into a new non form file with just a class, as I had intended upon essentially turning it into a library and making the code a little more proper and readable. As I didn't know exactly what had caused the error when it happened and had made a small plethora of changes, it took some time to track. Even after reversing the code, I managed to miss a pair of methods.
The methods for the main form containing the class Form with initializeComponent and form constructor (load). A 2nd copy of these methods appeared to result in the same error. Even after deleting the extra code and extra form and resx files. I even tried deleting the legitimate resx file since it was not actively needed. I was unable to effectively track it, because any errors pointed to the legit versions of these code segments. Ctrl+F and backup copies are your friends.
Hope that helps someone
Upvotes: -1
Reputation: 329
i did a little search i had the same problem it's probably beacause your form has two .resx if you try to delete one, the problem will be gone my form:
Form1.Designer.cs
Form1.resx
Log_in.resx
Form1
i deleted Log_in.resx and my program worked again
Upvotes: 4
Reputation: 121
This just happened to me. I had accidentally "Drag and dropped" a form into another. It ended up making a copy of it called "Copy of ". I deleted it and the problem went away.
Upvotes: 1
Reputation: 5265
This can happen in the event of two .resx files pointing to the same form. Mostly happens when renaming forms (other reasons may apply, I'm not exactly sure)
If your particular form files looks like this:
Form1.cs
Form1.designer.cs
MyFormerFormName.resx
Form1.resx
then that usually implies that you renamed the form but Visual Studio didn't remove the old .resx file. Once you delete the file (in this example MyFormerFormName.resx
) manually, the error should be gone upon next build.
Upvotes: 97
Reputation: 17186
I confirm WimOmbelets answer given in the comments. This can apparently happen when you rename a class in VS2012 (I never had this in a prior version).
I can't be sure this is the cause, but one thing I did different from my normal way is I used F2 to rename it as opposed to changing it and then pressing control-.
Upvotes: -2