With Prism, is it possible for two modules to reference different versions of the same assembly?
In my company, different teams are developing different modules of the same product based on WPF. Some modules reference the same assemblies e.g. Log4net, in-house framework, etc... To minimize the impacts, we would like each team to be able to update the version of the assemblies referenced by its module without forcing other teams to do the same. Is it possible with Prism?
This is possible but has nothing to do with Prism. What you will need to look at is using binding redirects.
Binding redirects allow you to specify that any reference to version X of an assembly should actually use version Y. This way the different teams may update their dependencies separately to one another but when it comes to deploying the application, you may configure the binding redirects to all point to a version of the assembly.
It is often usual to redirect the references to the most recent version of an assembly which has not introduced any breaking changes. Breaking changes could result in exceptions at runtime.
Here is an example of a binding redirect:
<dependentAssembly> <assemblyIdentity name="OurInHouseLibrary" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" /> <bindingRedirect oldVersion="18.104.22.168-22.214.171.124762" newVersion="126.96.36.199762" /> </dependentAssembly>
This specifies that any reference to the assembly OurInHouseLibrary of versions 188.8.131.52 through to version 184.108.40.206762 should now reference the assembly OurInHouseLibrary at version 220.127.116.11762.
I would suggest against it, but another option is to use the codeBase element to redirect to different assemblies, i.e.:
<dependentAssembly> <assemblyIdentity name="OurInHouseLibrary" publicKeyToken="32ab4ba45e0a69a1" culture="en-us" /> <codeBase version="18.104.22.168" href="v1.0\OurInHouseLibrary.dll" /> <codeBase version="22.214.171.124" href="v1.1\OurInHouseLibrary.dll" /> </dependentAssembly>
Here is an article from Microsoft explaining why loading multiple versions of the same assembly is a bad thing. One of the main issues is with Type identities, as you will not be able to use the type from one version in place of the type from another (including being unable to cast them).