error in csproj - duplicate item

For those who encountered the same problem, nothing helped them and they do not want to recreate the project: Try to delete YourPojectName.csproj.user file. It helped me. I modified the .csproj manually before and the modification introduced (somehow) probably some discrepancy to the two files.


I was facing the same problem in my solution with the same error for one of the source file,

I fixed it out as follows,

  1. Check for the file name for which the error is given.

  2. Find out in which project the file is included.

  3. Open the .csproj file for that particular project (This file can be found in the directory where solution is placed).

  4. Search for the file name for which the error is thrown in the .csproj file.

  5. You will find two entries of the line such as

 <Compile Include="duplicate.aspx.cs">
      <SubType>ASPXCodeBehind</SubType>
      <DependentUpon>Duplicate.aspx</DependentUpon>
    </Compile>


 <Compile Include="duplicate.aspx.cs">
      <SubType>ASPXCodeBehind</SubType>
      <DependentUpon>Duplicate.aspx</DependentUpon>
    </Compile>
  1. Delete any one line from one of them.

  2. Save the changes.

  3. Reload the project your error must have gone.


Easy! Just right clic in your project and select "Unload Project"

Right clic one again and edir your_project.csproj

Search a duplicate tag for the file mentioned in the error message.

Save and right clic to choose "Reload Project"

Right click


You could just open the solution in a regular text editor and remove the dups by hand