Composing/Ignoring different parts based on context

Apr 2, 2014 at 11:30 PM
Edited Apr 2, 2014 at 11:31 PM
Hello,

We currently use MEF like this:

Machine A:
  • Server.exe
  • ServerOnlyStuff.dll
  • MEF.Extension1.Server.dll
  • Extension1.Shared.dll
Machine B:
  • Client.exe
  • ClientOnlyStuff.dll
  • MEF.Extension1.Client.dll
  • Extension1.Shared.dll
That is, we keep assemblies imported by the font end separate from those imported by the back end. This way, Server.exe doesn't need to know about ClientOnlyStuff.dll, and Client.exe doesn't need to know about ServerOnlyStuff.dll. It keeps out unnecessary dependency.

I'd like to do this instead:

Machine A:
  • Server.exe
  • ServerOnlyStuff.dll
  • MEF.Extension1.dll <-- Same DLL
Machine B:
  • Client.exe
  • ClientOnlyStuff.dll
  • MEF.Extension1.dll <-- Different Context
If I set this up, composition chokes (ReflectionTypeLoadException). On Machine A this is because MEF.Extension1.dll references ClientOnlyStuff.dll, which is not there. On Machine B it chokes because MEF.Extension1.dll references ServerOnlyStuff.dll, which is not there.

I would like to be able to compose only the parts whose dependencies are present. This way a single dll could provide context-appropriate functionality in a number of locations.

One way to do this would be to allow developers to specify which namespace, within the target assembly, they're after.

Is there anything like what I'm talking about that I've missed, or is this a feature request?

Thanks for taking the time to read this, and thanks in advance for any advice you have for me.