My project references Library1.dll and Library2.dll. Library2.dll has a dependency on Library1.dll, but it was compiled to reference it by a different name, Library1.Net40.dll.
Is there an nice way tell my application to redirect all references for Library1.Net40.dll to resolve to Library1.dll? Maybe something similar to the way you can redirect versions using a <bindingRedirect>?
I've got a solution that handles the AppDomain.AssemblyResolve event, but it's a bit of a hack and am hoping there's a better way to do this.
Edit: For anyone's reference, here's how I ended up solving it using the AppDomain.AssemblyResolve event to redirect to a different assembly.
Have you tried playing with the <codeBase> element?
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Library1.Net40"
publicKeyToken="..."
culture="neutral" />
<codeBase version="2.0.0.0"
href="Library1.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
(Untested; no idea if it works.)
CF: Am putting this update here, because it's a bit long for the comments :)
Good idea, thanks. I got the redirect working but it complains because the names are different, here's the log:
LOG: Attempting download of new URL file:///C:/Project/bin/Library1.dll. LOG: Assembly download was successful. Attempting setup of file: C:\Project\bin\Library1.dll LOG: Entering download cache setup phase. LOG: Assembly Name is: Library1, Version=3.5.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed WRN: Comparing the assembly name resulted in the mismatch: NAME ERR: The assembly reference did not match the assembly definition found. ERR: Setup failed with hr = 0x80131040. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With