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

Azure.Core程序集Web.Config绑定重定向失效问题求助

Azure.Core程序集版本不匹配问题解决方案

问题描述

我有一个Microsoft网站项目(不同于Web Application项目),项目中包含版本为1.20.0.0的Azure.Core.dll程序集,但项目中的某.cs文件调用的是1.15.0.0版本,出现如下错误:

Could not load file or assembly 'Azure.Core, Version=1.15.0.0, Culture=neutral, PublicKeyToken=92742159e12e44c8' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

已在web.config中添加绑定重定向配置,但问题依旧:

<dependentAssembly>
    <assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-1.20.0.0" newVersion="1.20.0.0" />
</dependentAssembly>

尝试引入其他正常运行的同类项目的共享程序集无效,且无法卸载该网站项目(右键菜单无卸载选项),也无法修改项目类型或提供更多代码细节。

解决方法

  • 检查绑定重定向配置位置:确保配置放在<configuration>→<runtime>→<assemblyBinding>节点下,节点层级错误会直接导致配置不生效。完整的正确结构示例:

    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="Azure.Core" publicKeyToken="92742159e12e44c8" culture="neutral" />
            <bindingRedirect oldVersion="0.0.0.0-1.20.0.0" newVersion="1.20.0.0" />
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    
  • 清理bin目录残留文件:删除网站项目bin目录下所有文件,重新生成项目,确保目录中只有1.20.0.0版本的Azure.Core.dll,避免旧版本程序集干扰加载。

  • 用程序集绑定日志查看器排查细节:打开Visual Studio命令提示符,运行fuslogvw.exe,启用程序集绑定日志记录,查看具体的加载失败原因——比如是否有其他依赖组件强制要求1.15.0.0版本,或者绑定重定向规则未被系统应用。

  • 检查项目引用(若可访问):如果能找到项目的.csproj文件,打开后检查是否存在对Azure.Core 1.15.0.0的直接引用,将其替换为1.20.0.0版本。若是文件系统类型的网站项目,直接确认bin目录内的程序集版本是否正确。

  • 清理解决方案缓存:执行“清理解决方案”操作,手动删除所有项目的bin和obj目录,再重新生成整个解决方案,彻底清除旧的编译缓存文件。

  • 排查配置文件冲突:检查是否存在web.config转换文件(如web.release.config)或子目录下的web.config文件,这些文件可能会覆盖根目录的绑定重定向设置,确保所有相关配置文件中的规则一致。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.20 22:14:56