18 September, 2015

How to load strong named assembly from the location out of application base directory to new application domain

I found the only one decision: dynamically generate the configuration file in temporary folder:
<?xml version="1.0" encoding="utf-8"?>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="YYY" culture="" publicKeyToken="0123456789012345" />
        <codeBase version="K.L.M.N" href="file:///X:/XXX/YYY.DLL" />
        <assemblyIdentity name="ZZZ" culture="" publicKeyToken="1234567890123456" />
        <codeBase version="A.B.C.D" href="file:///X:/XXX/ZZZ.DLL" />
And set it to AppDomainSetup.ConfigurationFile:
var appDomain = AppDomain.CreateDomain("MyDomain", null, new AppDomainSetup
    ConfigurationFile = configFile