This project has moved and is read-only. For the latest updates, please go here.

Service Location in MEF

Jan 13, 2011 at 2: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 4:05 PM
Edited Jan 13, 2011 at 4: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; }