views:

101

answers:

2

I've got CS1703, which is a duplicate reference error. But, I've definitely only imported it once, and I tried removing my only actual reference, and it's still throwing. The compiler (VS2010) refuses to tell me where it thinks the other references are, so how on earth am I supposed to fix the error?

Edit: I looked into my .csproj, and there were indeed two references. I deleted one. No change. I found multiple references with the same PublicKeyToken as the error message. I removed them. No change.

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{613BA79B-7832-47A9-A8EA-67FCB0350C45}</ProjectGuid>
    <ProjectTypeGuids>{82b43b9b-a64c-4715-b499-d71e9ca2bd60};{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>Microsoft.SimplePackage</RootNamespace>
    <AssemblyName>SimplePackage</AssemblyName>
    <SignAssembly>True</SignAssembly>
    <AssemblyOriginatorKeyFile>Key.snk</AssemblyOriginatorKeyFile>
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <RunCodeAnalysis>true</RunCodeAnalysis>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="Microsoft.VisualStudio.OLE.Interop" />
    <Reference Include="Microsoft.VisualStudio.Shell.Interop" />
    <Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />
    <Reference Include="Microsoft.VisualStudio.Shell.Interop.9.0" />
    <Reference Include="Microsoft.VisualStudio.Shell.Interop.10.0" />
    <Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
    <Reference Include="Microsoft.VisualStudio.Shell.10.0">
      <Private>false</Private>
    </Reference>
    <Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Data" />
    <Reference Include="System.Design" />
    <Reference Include="System.Drawing" />
    <Reference Include="System.Windows.Forms" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <COMReference Include="EnvDTE">
      <Guid>{80CC9F66-E7D8-4DDD-85B6-D9E6CD0E93E2}</Guid>
      <VersionMajor>8</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </COMReference>
    <COMReference Include="EnvDTE100">
      <Guid>{26AD1324-4B7C-44BC-84F8-B86AED45729F}</Guid>
      <VersionMajor>10</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </COMReference>
    <COMReference Include="EnvDTE80">
      <Guid>{1A31287A-4D7D-413E-8E32-3B374931BD89}</Guid>
      <VersionMajor>8</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </COMReference>
    <COMReference Include="EnvDTE90">
      <Guid>{2CE2370E-D744-4936-A090-3FFFE667B0E1}</Guid>
      <VersionMajor>9</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </COMReference>
    <COMReference Include="Microsoft.VisualStudio.CommandBars">
      <Guid>{1CBA492E-7263-47BB-87FE-639000619B15}</Guid>
      <VersionMajor>8</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </COMReference>
    <COMReference Include="stdole">
      <Guid>{00020430-0000-0000-C000-000000000046}</Guid>
      <VersionMajor>2</VersionMajor>
      <VersionMinor>0</VersionMinor>
      <Lcid>0</Lcid>
      <WrapperTool>primary</WrapperTool>
      <Isolated>False</Isolated>
      <EmbedInteropTypes>False</EmbedInteropTypes>
    </COMReference>
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Guids.cs" />
    <Compile Include="Resources.Designer.cs">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="GlobalSuppressions.cs" />
    <Compile Include="SimplePackagePackage.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="SimpleProjectFactory.cs" />
    <None Include="Templates\Projects\SimpleProject\AssemblyInfo.cs" />
    <Content Include="Templates\Projects\SimpleProject\Program.cs">
      <IncludeInVSIX>true</IncludeInVSIX>
    </Content>
    <Content Include="Templates\Projects\SimpleProject\SimpleProject.wcproj">
      <IncludeInVSIX>true</IncludeInVSIX>
    </Content>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="Resources.resx">
      <Generator>ResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <EmbeddedResource Include="VSPackage.resx">
      <MergeWithCTO>true</MergeWithCTO>
      <ManifestResourceName>VSPackage</ManifestResourceName>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <None Include="source.extension.vsixmanifest">
      <SubType>Designer</SubType>
    </None>
  </ItemGroup>
  <ItemGroup>
    <None Include="Key.snk" />
  </ItemGroup>
  <ItemGroup>
    <Content Include="Resources\Package.ico" />
    <Content Include="Templates\Projects\SimpleProject\SimpleProject.ico">
      <IncludeInVSIX>true</IncludeInVSIX>
    </Content>
  </ItemGroup>
  <PropertyGroup>
    <UseCodebase>true</UseCodebase>
    <ProjectBasePath>C:\MyLocalFolder\Project</ProjectBasePath>
  </PropertyGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
  <Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\VSSDK\Microsoft.VsSDK.targets" />
  <Import Project="$(ProjectBasePath)\ProjectBase.Files" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>

Here's my project file, if any of you are curious. I'm following an extensibility guide on MSDN, so it looks a little different to a normal project file.

I hate assemblies. Please, dear God, Microsoft, name them something USEFUL.

+4  A: 

Open the project file (in Solution Explorer, right click the project and select "unload", then right click the project again and select "edit project file...") and go through the xml and delete all possible references manually.

Also, references are usually "stored" with a guid - before you delete the node that specifies the name of the assembly, search for the guid in the project file and see if there's anything else you need to remove as well.

As a third measurement, make sure you haven't referenced a namespace (for example for automatic import) multiple times in app/web.config.

Update: I noticed you published your project file. At the bottom, you're referencing another project (ProjectBase.Files) which I assume is yours too. Do the same error checking in this project, since this type of error sometimes tends to bubble back and forth.

Tomas Lycken
I went through the project file repeatedly and deleted a few references. No improvement. I also haven't used automatic import.. ever. Went through all my files and none of them double-use a namespace. Hell, I never even use the assembly referred to.
DeadMG
@DeadMG, see my update. Did that help?
Tomas Lycken
@Tomas: It's not actually another project. It's a bunch of source files, written by Microsoft. Doesn't have any actual references in it. There's no project file, for example. In addition, I've been using it for a while and not had this error previously.
DeadMG
@DeadMG: Have you tried removing *all* references to *all* EnvDTE versions, and then re-adding the ones you need?
Tomas Lycken
@Tomas: I did that, and then something very strange happened- EnvDTE80 reference magically reanimated itself. I cut it from the .csproj file. Now all I'm doing is trying to find the references I need. I hate .NET. And using directives suck. What the hell is a "Dispatcher" and how on earth am I supposed to know what assembly it's in? Not least that my assembly list contains loads of duplicates and assemblies that really, really could be just one assembly.
DeadMG
@DeadMG: I'm sorry to hear that you hate .NET, since you're apparently using it :P I hope you find what you need though.
Tomas Lycken
@Tomas Lycken: I'm using it because VS wants extensions in it. I'm a C++ man.. trying to extend C++.. in C#? It didn't make much sense to me either, but the alternative is writing a new C++ compiler from scratch, something that I don't really feel like.
DeadMG
A: 

now that is not very useful now is it? enable diagnostic build verbosity, do a build and post the csc command line, you should see which reference is passed 2 times to the compiler, easy

Ion Todirel