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

.NET 4.6.2应用System.Runtime.InteropServices.RuntimeInformation版本匹配异常求助

解决System.Runtime.InteropServices.RuntimeInformation版本冲突问题

针对你遇到的.NET 4.6.2环境下程序集版本不匹配问题,可尝试以下解决方案:

1. 添加程序集绑定重定向

在应用的app.config(或web.config)中添加绑定重定向规则,将对4.0.1.0版本的请求重定向到实际存在的4.0.2.0版本:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation"
                          publicKeyToken="b03f5f7f11d50a3a"
                          culture="neutral" />
        <bindingRedirect oldVersion="4.0.1.0"
                         newVersion="4.0.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

2. 统一NuGet包版本

  • 若使用packages.config:在文件中手动指定System.Runtime.InteropServices.RuntimeInformation的版本为4.0.1.0,执行NuGet包还原后重新编译,确保输出目录生成对应版本的DLL。
  • 若使用PackageReference:在项目文件(.csproj)中锁定该包的版本,让所有依赖项统一使用同一版本:
<PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.0.1.0" />

同时可在NuGet包管理器中检查TopShelf、CliWrap等依赖包的版本,确认它们对该程序集的依赖是否能通过统一版本解决冲突。

3. 调整Topshelf版本

Topshelf 4.3.0对.NET 4.6.2的适配可能存在版本依赖问题,可尝试降级Topshelf到更适配.NET 4.6.2的版本(如4.2.x系列),或查看Topshelf官方文档确认其在.NET 4.6.2环境下的推荐依赖版本。

4. 清理并重新生成项目

  • 执行Visual Studio的清理解决方案操作,删除项目的bin和obj目录。
  • 重新执行NuGet包还原,然后重新编译项目,确保输出目录中的DLL版本与IDE引用的版本一致。

内容的提问来源于stack exchange,提问作者Kerim Emurla

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.03 14:25:29