This project has moved. For the latest updates, please go here.

Service Location in MEF

Jan 13, 2011 at 1:36 PM

Hi Guys,

Any idea on how to perform Service location in MEF. Generally if we need to get a exported contract or service, we use GetExportedValue/GetExports<Type> etc.

Is there any better way to perform service location?

Any links/helps/pointers appreciated.




Jan 13, 2011 at 3:05 PM
Edited Jan 13, 2011 at 3:09 PM

Why not just stick to dependency injection? For example instead of doing

var foo = container.GetExportedValue<IFoo>();

you should do this:


public IFoo Foo { get; set; }