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

多目标框架(netcoreapp3.1+net48)下System.Runtime版本冲突求助

解决方案:多目标netcoreapp3.1/net48下System.Runtime版本冲突问题

针对你遇到的net48目标启动崩溃、System.Runtime版本冲突问题,可尝试以下方案:

1. 针对net48排除不必要的System.Runtime NuGet包

.NET Framework 4.8自身已包含System.Runtime组件,无需通过NuGet安装额外版本。在项目文件中添加以下配置,对net48目标移除该NuGet包引用:

<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
  <PackageReference Remove="System.Runtime" />
</ItemGroup>

2. 强制生成正确的绑定重定向

修改项目文件,针对net48目标开启自动绑定重定向并确保生效:

<PropertyGroup Condition="'$(TargetFramework)' == 'net48'">
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
  <ForceImportBeforeCppTargets>true</ForceImportBeforeCppTargets>
</PropertyGroup>

构建后检查输出目录下的[你的应用名].config文件,确认绑定重定向已正确生成。如果之前手动添加的重定向未生效,建议删除手动配置,依赖自动生成的规则。

3. 排查第三方API的依赖链

使用以下命令查看net48目标的完整依赖树,定位引入System.Runtime 4.2.2.0的间接依赖:

dotnet list package --include-transitive --framework net48

找到对应依赖包后,尝试升级到兼容.NET Framework 4.8的版本,从根源解决版本冲突。

4. 手动指定精确的绑定重定向规则

如果自动生成的重定向仍无效,可修改app.config中的绑定规则,将请求的4.2.2.0版本重定向到.NET Framework 4.8自带的System.Runtime版本(通常为4.0.0.0):

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
    <bindingRedirect oldVersion="0.0.0.0-4.2.2.0" newVersion="4.0.0.0"/>
  </dependentAssembly>
</assemblyBinding>

内容的提问来源于stack exchange,提问作者Alex R

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 21:05:25