Error in csproj - duplicate element

I have a bug with visual studio 2010:

Error 1 The element "CrossDomainService.svc.cs" was specified more than once in the "Sources" parameter. Sources is not supported by duplicate items. WcfServiceDomain

and from msbuild

C: \ Windows \ Microsoft.NET \ Framework \ v4.0.30319 \ Microsoft.CSharp.targets (160.9): error MSB3105: the element "CrossDomainService.svc.cs" was specified more than o nce in the "Sources" parameter. Sources is not supported by duplicate items. [C: \ Inetpub \ Wwwroot \ axaptaWcfConnection \ WcfServiceDomain \ WcfSer viceDomain.csproj]

My csproj file:

<?xml version="1.0" encoding="utf-8"?> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <PropertyGroup> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <ProductVersion> </ProductVersion> <SchemaVersion>2.0</SchemaVersion> <ProjectGuid>{8D40933A-E036-4CD0-9003-314A692724D5}</ProjectGuid> <ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids> <OutputType>Library</OutputType> <AppDesignerFolder>Properties</AppDesignerFolder> <RootNamespace>WcfServiceDomain</RootNamespace> <AssemblyName>WcfServiceDomain</AssemblyName> <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkProfile /> <FileUpgradeFlags> </FileUpgradeFlags> <UpgradeBackupLocation> </UpgradeBackupLocation> <OldToolsVersion>4.0</OldToolsVersion> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> <DebugType>full</DebugType> <Optimize>false</Optimize> <OutputPath>bin\</OutputPath> <DefineConstants>DEBUG;TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <PlatformTarget>x86</PlatformTarget> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> <Optimize>true</Optimize> <OutputPath>bin\</OutputPath> <DefineConstants>TRACE</DefineConstants> <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> </PropertyGroup> <ItemGroup> <Reference Include="System.Web.ApplicationServices" /> <Reference Include="System.Web.DynamicData" /> <Reference Include="System.Web.Entity" /> <Reference Include="System.Configuration" /> <Reference Include="System.Drawing" /> <Reference Include="System.EnterpriseServices" /> <Reference Include="System.Runtime.Serialization" /> <Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel.Web" /> <Reference Include="System.Web.Services" /> </ItemGroup> <ItemGroup> <Content Include="ClientAccessPolicy.xml" /> <Content Include="CrossDomainService.svc" /> <Content Include="Service1.svc" /> <Content Include="Web.config"> <SubType>Designer</SubType> </Content> <Content Include="Web.Debug.config"> <DependentUpon>Web.config</DependentUpon> </Content> <Content Include="Web.Release.config"> <DependentUpon>Web.config</DependentUpon> </Content> </ItemGroup> <ItemGroup> <Compile Include="CrossDomainService.svc.cs"> <DependentUpon>CrossDomainService.svc</DependentUpon> </Compile> <Compile Include="ICrossDomainService.cs" /> <Compile Include="Service1.svc.cs"> <DependentUpon>Service1.svc</DependentUpon> </Compile> <Compile Include="IService1.cs" /> <Compile Include="Properties\AssemblyInfo.cs" /> </ItemGroup> <ProjectExtensions> <VisualStudio> <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}"> <WebProjectProperties> <UseIIS>False</UseIIS> <AutoAssignPort>True</AutoAssignPort> <DevelopmentServerPort>51421</DevelopmentServerPort> <DevelopmentServerVPath>/</DevelopmentServerVPath> <IISUrl> </IISUrl> <NTLMAuthentication>False</NTLMAuthentication> <UseCustomServer>False</UseCustomServer> <CustomServerUrl> </CustomServerUrl> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> </WebProjectProperties> </FlavorProperties> </VisualStudio> </ProjectExtensions> <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" /> </Project> 

I do not see duplicates: / Any idea from this error ??

+43
visual-studio-2010 projects-and-solutions msbuild
Dec 27 '10 at 15:34
source share
11 answers

The only solution was to recreate the project: /

0
Jan 21 2018-11-11T00:
source share

I encountered the same problem in my solution with the same error for one of the source files,

I fixed it as follows:

  • Check the name of the file for which the error is indicated.

  • Find out in which project the file is included.

  • Open the .csproj file for this specific project (this file can be found in the directory where the solution is located).

  • Find the name of the file for which the error is displayed in the .csproj file.

  • You will find two row entries, 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> 
  • Delete any one line from one of them.

  • Save the changes.

  • Reload the project, which may be missing.

+79
Jun 28 '13 at 9:42 on
source share

For those who faced the same problem, nothing helped them, and they do not want to recreate the project: try deleting the file YourPojectName.csproj.user. It helped me. I modified .csproj manually before and the change made (in some way) is probably some mismatch between these two files.

+5
Jun 10 '13 at 6:18
source share

You can simply open the solution in a regular text editor and manually delete duplicates

+4
Sep 16 2018-11-11T00:
source share

I think I encountered the same problem not so long ago. The solution was to remove the subtype from web.config, i.e.

 <Content Include="Web.config"> <SubType>Designer</SubType> </Content> 

To:

 <Content Include="Web.config"> </Content> 

Now, they have been added again, I'm not sure why. The search for additional information has not yet become clear. See: <Subtype> Constructor </ Subtype> Added then removed by Visual Studio when loading / unloading

+2
Feb 09 2018-11-11T00:
source share

I have the same problem, and the solution was to shorten and misinform the directory name (it was backup, and the date and time are separated by a semicolon).

+1
Jul 26. 2018-11-11T00:
source share

Easily! Just click on your project and select "Upload Project"

Right click again and edir your_project.csproj

Locate the duplicate tag for the file indicated in the error message.

Save and edit by click to select "Update Project"

Right click

+1
May 31 '16 at 17:24
source share

Open the WcfServiceDomain.csproj file with a text editor and find CrossDomainService.svc.cs

He will probably be there twice. Just delete one of the lines and the project will work again.

+1
Jan 31 '17 at 11:46
source share

I had to remove the class from the project and recreate it again to solve this problem.

0
Oct. 20 '14 at 16:40
source share

The way I fixed this problem was to go to the place where the file was included in this error and find that there are two identical files. Remove one of them and it should work.

I had to cancel the pending changes after the files disappeared, but after rebuilding it worked.

0
Mar 31 '17 at 10:05
source share

I did what I renamed this file. Then clean the solution (by clicking Build> Clean Solution). Then they built a solution.

Then rename the file to the original file name. Then the solution was cleaned and the solution was again built.

It worked for me. I do not know if this will work for you.

0
May 16 '17 at 1:13
source share



All Articles