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

AspNet Zero仅发布到IIS时出现启动错误的问题求助

解决方案
  • 清空部署目录后完整重发布

增量部署易导致部署目录残留多版本System.Runtime.InteropServices.RuntimeInformation.dll文件,即使本地项目版本一致,混存的不同版本程序集会触发加载匹配失败。请先删除C:\Websites\beta.n1plus.co.za\下所有文件,再将全新生成的发布包完整上传部署,禁止使用增量覆盖方式。

  • 排查GAC中的冲突版本

执行命令gacutil /l System.Runtime.InteropServices.RuntimeInformation查看全局程序集缓存中是否存在该程序集,若存在4.0.0.0版本,系统会优先加载GAC内的版本,导致本地绑定重定向规则失效。如有冲突,可执行gacutil /u System.Runtime.InteropServices.RuntimeInformation移除GAC中的版本。

  • 修正绑定重定向配置

先查看发布包中实际存在的System.Runtime.InteropServices.RuntimeInformation.dll的真实版本号,再调整绑定重定向规则的newVersion为该真实版本号,同时确认配置放在web.config的正确节点下,示例配置如下:

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="替换为实际dll版本号" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>
  • 清理缓存后重新生成发布包

先删除本地项目的bin、obj目录,执行nuget locals all -clear清理本地NuGet缓存,再重新还原NuGet包、编译项目、生成发布包,排除本地编译缓存导致的程序集版本异常。

  • 校验IIS应用程序池配置

确认站点对应应用程序池的.NET CLR版本设置为无托管代码,同时应用程序池运行身份对部署目录拥有可读、可执行权限。

内容的提问来源于stack exchange,提问作者Donald Jansen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 13:54:04