Wednesday, February 24, 2016

Castle.MicroKernel.Registration.AllTypes' is obsolete in ASP.NET MVC 5

In the event that you'll be referencing Castle Windsor 3.3.0 and incorporate the IOC container in your project, you will encounter the error stated by the title of this post. This happens when you use register the controllers to the IOC container using AllTypes class.

1
2
3
4
container.Register(AllTypes.FromThisAssembly()
      .Pick().If(t => t.Name.EndsWith("Controller"))
      .Configure(configurer => configurer.Named(configurer.Implementation.Name))
      .LifestylePerWebRequest());

This class has been deprecated in the recent versions of Castle Windsor. The solution is to update the Register method and replace AllTypes with Castle.MicroKernel.Registration.Classes.

1
2
3
4
container.Register(Classes.FromThisAssembly()
     .Pick().If(t=> t.Name.EndsWith("Controller"))
     .Configure(configurer => configurer.Named(configurer.Implementation.Name))
     .LifestylePerWebRequest());

0 comments:

Post a Comment