error in csproj – duplicate item

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.

Leave a Comment