Custom Driver - AssemblyRedirect
Hi,
i develop a custom orm driver for linqpad.
Currently i'm facing a problem regarding the assembly versions of the orm's driver.
It seems like for the driver's domain the orm driver assembly that i supply with my package is loaded.
But for the query domain, the orm driver assembly within the path of the custom strongly typed orm context is loaded.
Even though my driver always uses the most recent orm driver's version (which is downwardly compatible), i can't find a way to inform linqpad about the assembly version redirect, e.g.:
dependentAssembly
assemblyIdentity name="OrmDriverLib" publicKeyToken="" culture="neutral" /
bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" /
/dependentAssembly
So lets say, the custom strongly typed orm context references the version 2.0 of the orm driver and
my driver package the version 2.1.
On runtime i end up with both version loaded into the same app domain and e.g. reflection calls are failing due to version mismatches.
Is there a way to specify such an assembly redirect for the query domain or do i need to provider a single driver package for each orm version of the orm driver ?
Thanks in advance.
i develop a custom orm driver for linqpad.
Currently i'm facing a problem regarding the assembly versions of the orm's driver.
It seems like for the driver's domain the orm driver assembly that i supply with my package is loaded.
But for the query domain, the orm driver assembly within the path of the custom strongly typed orm context is loaded.
Even though my driver always uses the most recent orm driver's version (which is downwardly compatible), i can't find a way to inform linqpad about the assembly version redirect, e.g.:
dependentAssembly
assemblyIdentity name="OrmDriverLib" publicKeyToken="" culture="neutral" /
bindingRedirect oldVersion="0.0.0.0-2.1.0.0" newVersion="2.1.0.0" /
/dependentAssembly
So lets say, the custom strongly typed orm context references the version 2.0 of the orm driver and
my driver package the version 2.1.
On runtime i end up with both version loaded into the same app domain and e.g. reflection calls are failing due to version mismatches.
Is there a way to specify such an assembly redirect for the query domain or do i need to provider a single driver package for each orm version of the orm driver ?
Thanks in advance.
Comments
Forcing a different ORM version onto the user can also break compatibility. Their code may depend on features that vary between versions - and they will not be programming defensively because they won't have anticipated that their code may have to run against a different ORM assembly.
As the driver writer, you are in a better position to anticipate this mismatch and code defensively such that you're likely to succeed against any ORM version.
If you want to go in this direction, the trick is to use the LoadAssemblySafely helper method as described in the LINQPad driver documentation. This will ensure that when in the query domain, you end up binding to the user's ORM rather than your own, and that you load only one version of the assembly.