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?
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.
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!
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With