Using MEFedMVVM together with Unity

Dec 21, 2010 at 10:42 AM

Hello,

I'm just making some tests with MEFedMVVM and CinchV2. It's pretty cool and I like the use this in my project. The problem is, that I'm using Microsoft's Unity Framework as my main IOC Container in my project. Is there any way, to use the MEF based MefedMVVM together with unity in the same project. That means some parts are injected by MEF (to use MEFedMVVM) and the others by Unity?

Thanks for help

Christoph

Coordinator
Dec 22, 2010 at 8:11 AM

Yes you can, however you might loose some of the flexibilities of the IOC since you would have 2 IOC now... In which case would you prefer using Unity instead of MEF?

Dec 22, 2010 at 10:17 AM

We have to use the Unity framework, as our project has to be configured through the app.config file. Therefore it is not possible to work with attributes within the project.

I found some kind of solution by using the Servicelocator and get the required implementation from there. But then, I'm loosing the design data in expression blend.

Coordinator
Dec 22, 2010 at 4:35 PM

is this silverlight or WPF?

Dec 22, 2010 at 5:05 PM

For WPF.

Coordinator
Dec 23, 2010 at 10:00 AM

You can try using this approach to get design time data using Unity.... 

 

http://marlongrech.wordpress.com/2009/09/02/service-locator-in-mvvm/

Dec 24, 2010 at 6:36 AM

Thanks for the hint. In the meantime I found another way to  get back the design time data. I'm now using a wrapper to make the implementation visible to mefedMVVM, depending on runtime or design time usage. This works very well for me, as I do not have to rewrite any of the existing code.