MEF in WebApi 2.0 does not allow

I am setting up MEF in WebApi 2.0 I originally looked at this example http://www.kennytordeur.blogspot.com/2012/08/mef-in-aspnet-mvc-4-and-webapi.html but in a later post How to integrate MEF with ASP.NET MVC 4 and ASP.NET Web API I saw that "DefaultControllerFactory with MVC is now a deprecated technique."

I am adjusting MefDependencyResolver and MefConfig based on a later post, but the webapi controller does not allow it because the value is still zero, also I noticed that the answer from the second post does not trigger composing. Does anyone know what I might be missing?

I am calling MefConfig.RegisterMef () on the Owin Startup.cs class. Earlier 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, imports have not yet been allowed. So I tried these two things.

+3


source to share


1 answer


I checked the constructor when I debug another method that resolved the dependency.



+1


source







All Articles