开发者

Duplicate reference error (C#)

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜