【问题标题】:Ignored "bindingredirect" starts working for no apparent reason忽略的“bindingredirect”无缘无故地开始工作
【发布时间】:2021-06-27 19:38:01
【问题描述】:

我有许多生成 dll 的项目和一个生成可执行文件的主项目,今天我成功编译了这些项目,但是当我尝试启动主项目时,我第一次遇到了下一个异常:“Assembly manifest definition does不匹配程序集引用”,所以不是我第一次重新编译项目并执行主项目没有问题,但现在我收到了这个错误。

检查异常后,我可以在导致它的 app.config 中找到“bindingredirect”,我检查了旧版本的系统,问题是这个“bindignredirect”始终存在于 app.config 中,但是以前从未抛出此错误,如果我评论 bindingredirect 行,则主项目开始时没有问题。

所有项目都将 .net 3.5 作为目标 .net 版本,这是什么原因造成的?有什么改变可以让 bindingredirect 现在执行?

App.config 部分

<!-- Habilita el debug just-in-time. -->
  <system.windows.forms jitDebugging="true" />
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="Componentes" publicKeyToken="BB48DC83EB7CD949" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.0.1.17726" newVersion="1.0.1.17261" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

InnerException的FusionLog

=== Información de estado anterior al enlace ===
LOG: Usuario = ymora
LOG: DisplayName = Componentes, Version=1.0.1.17265, Culture=neutral, PublicKeyToken=bb48dc83eb7cd949
 (Fully-specified)
LOG: Appbase = file:///E:/Yerald Mora/Documents/SISTEMAS/Principal/bin/
LOG: PrivatePath inicial = NULL
Ensamblado de llamada : Principal, Version=1.0.1.27092, Culture=neutral, PublicKeyToken=c078d737fbb55d54.
===
LOG: Este enlace empieza en el contexto de carga default.
LOG: Utilización del archivo de configuración de la aplicación: E:\Yerald Mora\Documents\SISTEMAS\Principal\bin\Principal.vshost.exe.config
LOG: Utilizando el archivo de configuración del equipo en C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
LOG: Redirección detectada en el archivo de configuración de aplicaciones: 1.0.1.17265 se redirigió a 1.0.1.17261.
LOG: Referencia posterior a la directiva: Componentes, Version=1.0.1.17261, Culture=neutral, PublicKeyToken=bb48dc83eb7cd949
LOG: Ya se detectó el mismo enlace, que generó un error hr = 0x80131040.

【问题讨论】:

    标签: .net visual-studio .net-assembly app-config


    【解决方案1】:

    用旧版本的系统进行测试,我意识到 dll 的版本号,在修订号中,它曾经以高于 17 的数字开头,例如 1.0.1.18463,这就是问题所在!。 ..,在 app.config 中的下一行确定 0.0.0.0 和 1.0.1.17726 之间的任何版本都应重定向到 1.0.1.17261

    <bindingRedirect oldVersion="0.0.0.0-1.0.1.17726" newVersion="1.0.1.17261" />
    

    在InnerException的FusionLog中下一行显示dll版本1.0.1.17265被重定向到1.0.1.17261

    LOG: Redirección detectada en el archivo de configuración de aplicaciones: 1.0.1.17265 se redirigió a 1.0.1.17261.
    

    所以,当我编译项目时,Visual Studio 生成了修订号 17265,这个在 appconfig 中建立的范围内,这就是之前到期的原因没有问题,因为修订号总是超出然后建立的范围appconfig 的属性 bindingredirect

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-13
      • 1970-01-01
      • 1970-01-01
      • 2019-03-21
      • 2021-11-22
      • 2014-02-24
      相关资源
      最近更新 更多