We are using Castel windsor for DI in our Sitecore solution. Though we haven't done any IOC registration using Sitecore pipelines, It still resolves the Controllers. I'm fine with it. But the same is not working for Pipeline processors,

for ex:

Public class MyPipelineClass
{
    private IMyDependency myDependency;

    public MyPilelineClass(IMyDependency _myDependency){
        this.myDependency = _myDependency;
    }

    public void Process(PipelineArgs args)
    {
         myDependency.Execute();
     }
}

How can I achieve this sort of injecting dependencies to constructor of sitecore pipeline processor from Windsor container?

I'm ready to provide any specific details that'll help answering this question.

up vote 3 down vote accepted

Assuming you're running Sitecore 8.2 or later, you can add resolve="true" to the <pipeline> element to enable DI resolution for the processor.

Sitecore uses Microsoft.Extensions.DependencyInjection for dependency injection, which doesn't appear to list Windsor as a supported container. It may be possible, but I'd seriously consider whether Windsor offers features/performance that make it worth it for your project to go "off the beaten path".

  • So, do you suggest using Microsoft.Extenstions.DependencyInjection for resolving pipelines, alongside using Castle Windsor for resolving Controllers?? – nari447 Apr 28 at 11:19
  • Controllers are automatically resolved using Microsoft.Extenstions.DependencyInjection by default. However, I believe the default container requires registration (ie. it won't look at a controller's ctor arguments unless you register it) – Richard Szalay Apr 28 at 11:51
  • Ok.. let me try this. – nari447 Apr 28 at 12:22
  • 1
    I've ended up using castle for controllers(will plan to change this to use sitecore dependency injestionl later) and Microft.Extensions.DependencyInjection for Sitecore pipelines for now... Thank you, Richard. – nari447 Apr 30 at 10:32

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.