How do I achieve assembly binding redirection in a plugin script?

I have an extension plugin P

and application A

(.NET40) that I have no control over.
Assembly P (.NET40) has shared dependency D

(.NET35).

Both P and D depend on FSharp.Core, but different versions:

P

compiled against FSharp.Core, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a


D

compiled againstFSharp.Core, Version=2.3.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

Only FSharp.Core, version = 4.4.0.0 is deployed and I subscribe to AppDomain.AssemblyResolve to load deployed assemblies.

While I'm testing on my machine, where both FSharp.Core versions are installed in the GAC, they are both loaded using the plugin.

My understanding is that an anchor redirect would be the solution here, but how can I do that without accessing app.config?

+3


source to share


1 answer


You can expand D as a collection .

The advantage of this approach is that client directories do not need to contain * .config files in order to redirect to a newer version. The publisher policy allows the assembly publisher to install the binary version of the * .config file in the GAC (along with the assembly). This way the CLR will be able to perform the requested redirect at the GAC level.



If you want to bypass the publisher policy for a specific application, you can specify this in the applications * .config file using the <publisherPolicy>

.

<?xml version="1.0" encoding="utf-8" ?>
<configuration> 
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
            <publisherPolicy apply="no" />
        </assemblyBinding>
    </runtime> 
</configuration>

      

+2


source







All Articles