3
votes

I'm working on a C#/MVC app that currently uses Windsor as a DI framework, and have just started exploring MEF to make the app more extensible. It's been working beautifully, right up till the point where my plugins need to have dependencies satisfied.

How can I inject Windsor managed dependencies into a class that is imported by MEF, preferably with [ImportingConstructor]?

I've tried extending ContainerAdapterBase from MefContrib but can't figure out how to get it to work with [ImportingConstructor]. Also, using MEF for IoC is not an option.

Thanks!

1
Have you considered creating your plugins with Windsor instead of using MEF (I'm not very familiar with MEF, but windsor is super extensible).Marwijn
I liked the idea of using MEF because its really simple and is what it is designed to do, and supports a few things Windsor doesn't like picking up classes in DLLs dropped at runtime. I'd much rather use Windsor for everything but feels a bit like shoe-horning it in where it's not the right tool.GoatInTheMachine

1 Answers

0
votes

Update: My current solution is to write a simple 'DSL', managed by Windsor, that provides all the functionality required by plug-ins, and then manually inject that whenever MEF passes me a plug-in instance. Possibly a bit nasty but it works, it also means I don't have to do any service location from plugins, and also provides a nice boundary around what a plugin is 'allowed' to do.

Any thoughts on this approach would be greatly appreciated.