I'm setting up MEF in a WebApi 2.0 Initially I looked at this example http://www.kennytordeur.blogspot.com/2012/08/mef-in-aspnet-mvc-4-and-webapi.html but in a more recent post How to integrate MEF with ASP.NET MVC 4 and ASP.NET Web API I saw that "DefaultControllerFactory with MVC is now an outdated technique".
I setup the MefDependencyResolver and the MefConfig based on the later post, but the webapi controller is not resolving it because the value is still null, also, I noticed the answer from the second post doesn't call compose parts. Does anyone know what I might be missing?
I'm calling MefConfig.RegisterMef() in an Owin Startup.cs class. Before in the startup class I had:
catalog = new AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly());
CompositionContainer container = new CompositionContainer(catalog, true);
container.ComposeParts(this);
configuration = new HttpConfiguration();
configuration.DependencyResolver = new MefDependencyResolver(container);
app.UseWebApi(configuration);
With this other method, the import was still not being resolved. So I've tried those two things.