You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

netcoreapp2.1项目重建遇CS1705版本冲突错误求助

解决.NET Core 2.1项目的CS1705程序集版本冲突问题

问题分析

错误提示System.Collections.Concurrent(版本4.0.14.0)依赖的System.Runtime版本为4.2.1.0,但当前项目引用的System.Runtime仅为4.1.0.0,导致版本不兼容。这类冲突通常由依赖包间接引入不同版本核心程序集,或AssetTargetFallback配置触发的兼容程序集冲突导致。

解决方案

1. 移除AssetTargetFallback配置

项目中添加的portable-net45+win8+wp8+wpa81回退目标,可能引入.NET Framework兼容程序集引发版本冲突,直接移除该配置:

<!-- 删除此行 -->
<AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>

2. 显式指定System.Runtime版本

在项目文件中添加System.Runtime的PackageReference,强制使用兼容.NET Core 2.1的版本:

<ItemGroup>
  <!-- 保留原有包引用,新增此行 -->
  <PackageReference Include="System.Runtime" Version="4.3.0" />
</ItemGroup>

4.3.0版本可覆盖低版本引用,同时满足System.Collections.Concurrent的依赖需求。

3. 清理NuGet缓存并重新还原

执行以下命令清理缓存,避免旧版本包干扰:

dotnet nuget locals all --clear
dotnet restore

4. 更新老旧依赖包(可选)

项目中使用的Abp 3.8.1版本较旧,存在潜在兼容问题,可更新至3.x系列的最新兼容版本:

<PackageReference Include="Abp.AutoMapper" Version="3.9.0" />
<PackageReference Include="Abp.ZeroCore.EntityFrameworkCore" Version="3.9.0" />

修改后的完整项目文件示例

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup Label="Globals">
    <SccProjectName>SAK</SccProjectName>
    <SccProvider>SAK</SccProvider>
    <SccAuxPath>SAK</SccAuxPath>
    <SccLocalPath>SAK</SccLocalPath>
  </PropertyGroup>
  <PropertyGroup>
    <VersionPrefix>1.0.0.0</VersionPrefix>
    <TargetFramework>netcoreapp2.1</TargetFramework>
    <AssemblyName>PortalLHP.Core</AssemblyName>
    <PackageId>PortalLHP.Core</PackageId>
    <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
    <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
    <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
    <UserSecretsId>AbpCompanyName-PortalLHP-56C2EF2F-ABD6-4EFC-AAF2-2E81C34E8FB1</UserSecretsId>
    <RootNamespace>PortalLHP</RootNamespace>
  </PropertyGroup>
  <ItemGroup>
    <EmbeddedResource Include="Localization\SourceFiles\*.xml" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Abp.AutoMapper" Version="3.9.0" />
    <PackageReference Include="Abp.ZeroCore.EntityFrameworkCore" Version="3.9.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
    <PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.1.1" />
    <PackageReference Include="Castle.Windsor.MsDependencyInjection" Version="3.3.1" />
    <PackageReference Include="Sendgrid" Version="9.9.0" />
    <PackageReference Include="Telerik.UI.for.AspNet.Core" Version="2018.1.503" />
    <PackageReference Include="System.Runtime" Version="4.3.0" />
  </ItemGroup>
</Project>

内容的提问来源于stack exchange,提问作者ellen kiswanto

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 11:10:00