The type 'System.Data.Services.DataService<T>' exists in both 'c:\Program Files (x86)\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.Services.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0...

คำตอบ The type 'System.Data.Services.DataService<T>' exists in both 'c:\Program Files (x86)\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.Services.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0...

  • 2012年4月10日 13:31
     
      コードあり

    I've installed WCF Data Services 5.0 RTM and added to an existing web project a "WCF Data Service (for OData V3)" item. I've set my DataService type but when I build the project I get these two errors:

    • The type 'System.Data.Services.DataService<T>' exists in both 'c:\Program Files (x86)\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.Services.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.Services.dll'
    • The type 'System.Data.Services.DataServiceConfiguration' exists in both 'c:\Program Files (x86)\Microsoft WCF Data Services\5.0\bin\.NETFramework\Microsoft.Data.Services.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Data.Services.dll'

    My .csproj file is below:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <PropertyGroup>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <ProductVersion>
        </ProductVersion>
        <SchemaVersion>2.0</SchemaVersion>
        <ProjectGuid>{4944278A-7BF9-42EB-BEF3-FECCA51BC755}</ProjectGuid>
        <ProjectTypeGuids>{E53F8FEA-EAE0-44A6-8774-FFD645390401};{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
        <OutputType>Library</OutputType>
        <AppDesignerFolder>Properties</AppDesignerFolder>
        <RootNamespace>LoggingReportWeb</RootNamespace>
        <AssemblyName>LoggingReportWeb</AssemblyName>
        <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
        <MvcBuildViews>false</MvcBuildViews>
        <UseIISExpress>false</UseIISExpress>
      </PropertyGroup>
      <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
        <DebugSymbols>true</DebugSymbols>
        <DebugType>full</DebugType>
        <Optimize>false</Optimize>
        <OutputPath>..\..\build\LoggingReportWeb\bin\</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\</OutputPath>
        <DefineConstants>TRACE</DefineConstants>
        <ErrorReport>prompt</ErrorReport>
        <WarningLevel>4</WarningLevel>
      </PropertyGroup>
      <ItemGroup>
        <Reference Include="Microsoft.Data.Edm, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="Microsoft.Data.OData, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="Microsoft.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="Microsoft.Data.Services.Client, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <HintPath>..\..\_Resources\ReportViewer\Microsoft.ReportViewer.Common.dll</HintPath>
          <Private>True</Private>
        </Reference>
        <Reference Include="Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
          <SpecificVersion>False</SpecificVersion>
          <HintPath>..\..\_Resources\ReportViewer\Microsoft.ReportViewer.WebForms.dll</HintPath>
          <Private>True</Private>
        </Reference>
        <Reference Include="System.Data.Entity" />
        <Reference Include="System.Data.Services" />
        <Reference Include="System.Data.Services.Client" />
        <Reference Include="System.Runtime.Serialization" />
        <Reference Include="System.Security" />
        <Reference Include="System.ServiceModel" />
        <Reference Include="System.ServiceModel.Web" />
        <Reference Include="System.Spatial, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
        <Reference Include="Microsoft.CSharp" />
        <Reference Include="System" />
        <Reference Include="System.Data" />
        <Reference Include="System.Drawing" />
        <Reference Include="System.Web.ApplicationServices" />
        <Reference Include="System.ComponentModel.DataAnnotations" />
        <Reference Include="System.Core" />
        <Reference Include="System.Data.DataSetExtensions" />
        <Reference Include="System.Web" />
        <Reference Include="System.Web.Extensions" />
        <Reference Include="System.Web.Abstractions" />
        <Reference Include="System.Web.Routing" />
        <Reference Include="System.Configuration" />
        <Reference Include="System.Web.Services" />
        <Reference Include="System.EnterpriseServices" />
        <Reference Include="System.Xml" />
      </ItemGroup>
      <ItemGroup>
        <Compile Include="Controllers\ReportController.cs" />
        <Compile Include="DataWarehouse.Designer.cs">
          <DependentUpon>DataWarehouse.edmx</DependentUpon>
          <AutoGen>True</AutoGen>
          <DesignTime>True</DesignTime>
        </Compile>
        <Compile Include="DataWarehouse.svc.cs">
          <DependentUpon>DataWarehouse.svc</DependentUpon>
        </Compile>
        <Compile Include="Global.asax.cs">
          <DependentUpon>Global.asax</DependentUpon>
        </Compile>
        <Compile Include="Models\Report\ReportSetting.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
        <Compile Include="ReportRouteHandler.cs" />
        <Compile Include="Reports\ReportWebForm.aspx.cs">
          <DependentUpon>ReportWebForm.aspx</DependentUpon>
          <SubType>ASPXCodeBehind</SubType>
        </Compile>
        <Compile Include="Reports\ReportWebForm.aspx.designer.cs">
          <DependentUpon>ReportWebForm.aspx</DependentUpon>
        </Compile>
      </ItemGroup>
      <ItemGroup>
        <Content Include="DataWarehouse.svc" />
        <Content Include="Global.asax" />
        <Content Include="Reports\ReportWebForm.aspx" />
        <Content Include="Web.config" />
        <Content Include="Views\Web.config" />
        <Content Include="Views\_ViewStart.cshtml" />
        <Content Include="Views\Shared\Error.cshtml" />
        <Content Include="Views\Shared\_Layout.cshtml" />
        <None Include="_bin_deployableAssemblies\Microsoft.Web.Infrastructure.dll" />
        <None Include="_bin_deployableAssemblies\System.Web.WebPages.Razor.dll" />
        <None Include="_bin_deployableAssemblies\System.Web.WebPages.dll" />
        <None Include="_bin_deployableAssemblies\System.Web.WebPages.Deployment.dll" />
        <None Include="_bin_deployableAssemblies\System.Web.Razor.dll" />
        <None Include="_bin_deployableAssemblies\System.Web.Helpers.dll" />
        <None Include="_bin_deployableAssemblies\System.Web.Mvc.dll" />
      </ItemGroup>
      <ItemGroup>
        <Folder Include="Content\" />
        <Folder Include="Scripts\" />
      </ItemGroup>
      <ItemGroup>
        <Content Include="Views\Report\Index.cshtml" />
      </ItemGroup>
      <ItemGroup>
        <EntityDeploy Include="DataWarehouse.edmx">
          <Generator>EntityModelCodeGenerator</Generator>
          <LastGenOutput>DataWarehouse.Designer.cs</LastGenOutput>
        </EntityDeploy>
      </ItemGroup>
      <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
      <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
      <!-- 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> -->
      <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
        <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
      </Target>
      <ProjectExtensions>
        <VisualStudio>
          <FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
            <WebProjectProperties>
              <UseIIS>False</UseIIS>
              <AutoAssignPort>True</AutoAssignPort>
              <DevelopmentServerPort>50597</DevelopmentServerPort>
              <DevelopmentServerVPath>/</DevelopmentServerVPath>
              <IISUrl>
              </IISUrl>
              <NTLMAuthentication>False</NTLMAuthentication>
              <UseCustomServer>False</UseCustomServer>
              <CustomServerUrl>
              </CustomServerUrl>
              <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
            </WebProjectProperties>
          </FlavorProperties>
        </VisualStudio>
      </ProjectExtensions>
      <PropertyGroup>
        <PostBuildEvent>xcopy /Y/D/S/I "$(ProjectDir)*.svc" "$(TargetDir)..\"
    xcopy /Y/D/S/I "$(ProjectDir)*.config" "$(TargetDir)..\"
    xcopy /Y/D/S/I "$(ProjectDir)*.edmx" "$(TargetDir)..\"
    xcopy /Y/D/S/I "$(ProjectDir)*.cshtml" "$(TargetDir)..\"
    xcopy /Y/D/S/I "$(ProjectDir)*.aspx" "$(TargetDir)..\"
    xcopy /Y/D/S/I "$(ProjectDir)*.asax" "$(TargetDir)..\"</PostBuildEvent>
      </PropertyGroup>
    </Project>

すべての返信

  • 2012年4月10日 13:43
     
     回答済み
    I removed and re-added a bunch of references (anything containing the words Data, Entity, Services etc) and that seems to have fixed it. I think the simple version of the fix is to remove the reference to System.Data.Services as it's no longer needed and is replaced by Microsoft.Data.Services.
    • 回答としてマーク tjrobinson 2012年4月10日 13:43
    •  
  • 2012年4月11日 1:25
    モデレータ
     
     

    Hi tjrobinson,

    Thanks for sharing your experience here.

    Have a nice day.


    Alan Chen[MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.