Sep 24, 2008 at 2:28 AM
I've come up with a solution to
work item #1014 which involves MRefBuilder not being able to resolve references to assemblies that have redirects to different versions. The solution is fairly simple and involves replacing the default assembly resolver in the MRefBuilder.config
file with a custom version that allows you to specify the redirects to use on the assemblies it can't resolve in the default version.
The code and assembly are attached to the work item (CustomResolver.zip). To use it, update your
MRefBuilder.config file by replacing the resolver element with something similar to the following. SHFB users will need to modify the template found in the
.\Templates folder under the SHFB installation folder. A plug-in can be written to make this automatic but it will have to wait for a later release. For now, just hard-code the stuff you need in it.
<!-- Replace the resolver element with this. Update the path
to point to the location of the assembly on your system. -->
<!-- Add redirects for each reference it can't find telling it
which strong name to use instead. Multiple redirects can be
specified for the same missing reference if necessary to
provide multiple choices. The first one found is used. -->
from="NationalInstruments.Common, Version=184.108.40.206, Culture=neutral, PublicKeyToken=4544464cdeaab541"
to="NationalInstruments.Common, Version=220.127.116.11, Culture=neutral, PublicKeyToken=4544464cdeaab541" />
Add a Redirect element as indicated to tell MRefBuilder which strong name to use in place of the one it can't find. The
from attribute references the strong name that MRefBuilder cannot resolve. The
to attribute references the strong name of the redirected assembly to use in its place. The redirected assembly with that strong name must be specified as a dependency via the
/dep command line option (the Dependencies property in SHFB).
The code was tested using the demo assemblies attached to the work item by the original poster. Please note that I don't use those assemblies myself so I cannot answer specific questions about them or their classes, just the custom assembly resolver and
how it works. If you have any questions or problems, post here.