I am trying to inject a dependency into a controller that inherits from Umbraco RenderMvcController and gets an error
"No registration for type RenderMvcController can be found and implicit registration cannot be done. For a container to create a RenderMvcController, it must have only one public constructor: it has 3. See https://simpleinjector.org/one-constructor for more information. "
Below is my code for connecting DI
var container = new Container(); container.Options.DefaultScopedLifestyle = new WebRequestLifestyle(); InitializeContainer(container); container.RegisterMvcControllers(Assembly.GetExecutingAssembly()); container.Verify(); DependencyResolver.SetResolver(new SimpleInjectorDependencyResolver(container)); private static void InitializeContainer(Container container) { container.Register<ICacheProvider, CacheProvider>(Lifestyle.Transient); container.Register<ICacheService, CacheService>(Lifestyle.Transient); }
This is an example of a class receiving a dependency; it inherits from the base class that I wrote
public class NewsroomController : BaseRenderMvcController { public NewsroomController(ICacheService cacheService) : base(cacheService) { }
The base class extends the RenderMvcController, which is the Umbraco controller
public class BaseRenderMvcController : RenderMvcController { public ICacheService CacheService { get; set; } public BaseRenderMvcController(ICacheService cacheService) { CacheService = cacheService; } }
As you can see, the Umbraco base controller actually has 3 different constructors
public class RenderMvcController : UmbracoController, IRenderMvcController, IRenderController, IController { public RenderMvcController(); public RenderMvcController(UmbracoContext umbracoContext); public RenderMvcController(UmbracoContext umbracoContext, UmbracoHelper umbracoHelper);
I'm not sure how to get SimpleInjector to fit well with this controller, inherited from Umbraco.
Thanks in advance!