This is a custom assembly resolver for Sandcastle's MRefBuilder tool that supports assembly binding redirect elements in its configuration that let you redirect an unknown assembly's strong name to another by version number when resolving an unknown reference.

Namespace: SandcastleBuilder.Components
Assembly: SandcastleBuilder.MRefBuilder (in SandcastleBuilder.MRefBuilder.dll) Version: 1.9.3.0

Syntax

C#
public class BindingRedirectResolver : AssemblyResolver
Visual Basic
Public Class BindingRedirectResolver _
	Inherits AssemblyResolver

Remarks

This solves the problem reported in Sandcastle work item #1014. To use the resolver, it must be added to the MRefBuilder.config file by defining the resolver element as shown in the example below. Within the resolver element, add an assemblyBinding element that contains one or more dependentAssembly elements that define the redirections. If you have a set of redirections in an application or web configuration file, you can define a dependentAssembly element with an importFrom attribute that specifies the location of the configuration file from which to import the redirects. The other option is to specify individual redirects using the assemblyIdentity and bindingRedirect child elements of each dependentAssembly element. See the MSDN help for those elements for more information on their usage.
Important
The assembly version(s) to which the entries are redirected must be one of the documented assemblies or must be referenced as a dependency using the /dep command line switch.

Examples

CopySample MRefBuilder.config
<configuration>
  <dduetools>
    <platform version="2.0"
      path="%SystemRoot%\Microsoft.NET\Framework\v2.0.50727\" />

    <!-- Replace the resolver element with this.  Update the path
         to point to the location of the assembly on your system. -->
    <resolver type="SandcastleBuilder.Components.BindingRedirectResolver"
        assembly="C:\SandcastleBuilder\SandcastleBuilder.MRefBuilder.dll"
        use-gac="false">

      <!-- Add an assemblyBinding element to contain the redirects -->
      <assemblyBinding>
        <!-- Import bindings from an application or web config file -->
        <dependentAssembly importFrom=".\Web.config" />

        <!-- Define a redirect for a range of versions -->
        <dependentAssembly>
          <assemblyIdentity name="NationalInstruments.Common"
              publicKeyToken="4544464cdeaab541" />
          <bindingRedirect oldVersion="1.0.0.0-8.1.20.168"
              newVersion="8.1.20.237" />
        </dependentAssembly>

        <!-- Define a redirect for a single version -->
        <dependentAssembly>
          <assemblyIdentity name="MyCompany.Util.ComponentFactory"
              publicKeyToken="E1458197622051B1" culture="neutral"/>
          <bindingRedirect oldVersion="1.2.3.4"
              newVersion="2.1.4.3"/>
        </dependentAssembly>

      </assemblyBinding>
    </resolver>

    <!-- ... rest of MRefBuilder.config ... -->

  </dduetools>
</configuration>

Inheritance Hierarchy

System..::..Object
  Microsoft.Ddue.Tools.Reflection..::..AssemblyResolver
    SandcastleBuilder.Components..::..BindingRedirectResolver

See Also