My target:
We are allowing to integrate our product with third party components (libraries) which are not installed as part of our product because of licensing. At the moment we want to load features related to third party components only if these components are installed on the client's machine.
Current solution:
I'm using Assembly.ReflectionOnlyLoad
with providing full names of third party assemblies to validate installation of third party components before the application loads related features. This works for following scenarios:
- Exact versions of libraries are installed to GAC
- Exact versions of libraries are copied to application directory / probing paths
Problem:
Now I need to modify the solution to support publisher policies (redirecting assembly binding to new version). I just tested my code and it looks like ReflectionOnlyLoad
ignores publisher policy deployed to GAC so my mechanism will not load expected features even third party assemblies are correctly installed (new version with assembly redirection).
If I remove my validation (= features will be loaded every time) the application will correctly load new version of third party assemblies so publisher policy works correctly because features are still compiled with dependency to old version.
How to validate existence of the assembly in both GAC and probing paths when using versioning and assembly redirection?