【问题标题】:How to locate an assembly which forces binding redirect如何定位强制绑定重定向的程序集
【发布时间】:2013-10-25 00:23:30
【问题描述】:

假设我们有:

  • 程序集 A 引用了 assebly NH 版本 2.0.0.0。
  • 程序集 B 引用了 assebly NH 版本 2.0.0.0。
  • 程序集 C 引用了 assebly NH 版本 1.0.0.0(意外)
  • 我们的测试网络项目引用了程序集 A、B、C 和 NH 2.0.0.0。

Nuget 有一个很棒的功能,它可以自动检测这些程序集冲突并创建绑定重定向指令。 Nuget 命令 Add-BindingRedirect 会将此类字符串添加到测试项目 web.config 文件中:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
      <assemblyIdentity name="NH" publicKeyToken="aa95f207798dfdb4" culture="neutral" />
      <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
    </dependentAssembly>
  </assemblyBinding>
</runtime>

现在假设我们有更多的库,引用 NH。 问题是:识别奇数版本的最佳(最好不是手动)方法是什么?

【问题讨论】:

  • 如果您可以在为log all binds 启用Fusion Log Viewer 的情况下运行您的应用程序。这应该会给你信息谁在加载什么以及哪个版本。
  • 感谢您的回复,我猜您应该将其发布为答案。

标签: .net nuget versioning


【解决方案1】:

要调查绑定错误,您可以使用Fusion Log Viewer

您可以将其配置为记录所有绑定,这基本上可以让您了解从何处加载了哪些程序集。

典型输出如下所示:

=== Pre-bind state information ===
LOG: DisplayName = graphicfailtest.resources, Version=0.0.0.0, Culture=en-US, PublicKeyToken=null
 (Fully-specified)
LOG: Appbase = C:\bla\graphic\cs\
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = NULL
Calling assembly : graphicfailtest, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.
===

LOG: Processing DEVPATH.
LOG: DEVPATH is not set. Falling through to regular bind.
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: graphicfailtest.resources, Version=0.0.0.0, Culture=en-US, PublicKeyToken=null
LOG: Attempting download of new URL file:///C:..../graphicfailtest.resources.DLL.
LOG: All probing URLs attempted and failed.

【讨论】:

    猜你喜欢
    • 2012-04-27
    • 2017-02-16
    • 2019-12-21
    • 1970-01-01
    • 1970-01-01
    • 2021-10-01
    • 2021-10-18
    • 2021-01-15
    • 1970-01-01
    相关资源
    最近更新 更多