Assembly Binding and Redirection

Here's a scenario that I was having trouble with this week.

You have an application that requires the assemblies to be versioned for each build. A third party wants to write a "plugin" that is called by your application that references assemblies from a particular version of the application's assemblies. How do you make the plugin useful for future builds without the need for re-compilation?

Firstly, there are some amazing tools available from Microsoft to help debug these types of issues:

What was interesting in this scenario was I was expecting to put the redirection on the plugin assembly. But actually I found that the publisher policy has to be set by the calling application. This is likely to be due to the fact that you can only have one set of policies per app domain and as the plugin was not sectioned off in its own app domain, it had to share with the parent. Hence it needed to be set at that level.

Once I had configured the version redirection in the parent application the plugins were able to run in versions that the plugin wasn't designed for. However if an interface or method changes down the line, well that's another story.