Two output file names resolved to the same output

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?


Solution 1:

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.

Solution 2:

Find Duplicates by Editing Project File

  1. Note the name of the .resx failure.

  2. Unload the project first by right clicking on your project then click Unload Project.

enter image description here

  1. Right click your project again and click edit project.

enter image description here

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!

Solution 3:

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.

Solution 4:

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