I have a DLL that uses assembly binding via it's .config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This is needed because the dependencies load conflicting versions of Newtonsoft.Json (6.0 vs. 9.0) and the binding is needed to resolve the conflict.
the problem I have is that this DLL is a Powershell module, and is loaded by powershell. Its .config
is ignored and the runtime throws exception:
My-cmdLet : Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral,
ublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.
Normally I would resolve this by modifying the hosting exe .config
file and adding the relevant dll section. But in this case the hosting .exe is Powershell, and I'd rather not mess with that .config
.
Is there a way the DLL itself can resolve the binding properly?