We have an app where we switch between different versions of a 3rd party interop library (AutoCad). The subset of the interop API we use is the same across all versions of the interop library.
What would be the most effective way to reference different versions of the library while reusing the client code?
One approach is to use reflection: define a wrapper type for each of the used interop interfaces and use reflection inside the wrappers to load the interop type from the specified version of the interop assembly and just proxy every call to the interop object. This approach looks wasteful to me when all the interfaces in the used subset are exactly the same across all versions of the interop.
Other approach would be to reference different interop assemblies in different configurations of the project. With the identical interfaces across interop assemblies this should allow to compile different versions of the client assembly for each version of the interop assembly. One thing I'm not sure how to implement in this approach is configuring the project so that it builds all the versions of the client assembly at the same time to include them all in a single distribution.
It should be possible to employ code gen here as well, but I'm not sure how difficult it could be.
How would you solve this kind of problem?
Thanks!