Skip to main content

Questions tagged [dependency-injection]

Anything related to the use of Dependency Injection (DI)/IoC containers on a Sitecore solution. This also includes the baked-in Microsoft Dependency Resolver included natively in Sitecore versions 8.2 and above.

Filter by
Sorted by
Tagged with
8 votes
6 answers
3k views

SXA custom component looking for parameterless constructor

I am trying to create my first SXA compatible component, and I can't seem to get everything setup quite right. I decompiled the Maps component, and am using it as my guide. I understand that I need to ...
Keith VanderVeen's user avatar
10 votes
4 answers
25k views

"No parameterless constructor defined for this object" after upgrade to Sitecore 8.2

We have upgraded our platform to Sitecore 8.2 recently and in the preview we are getting below error. We disabled all glass mapper related config. No parameterless constructor defined for this object....
Chandra Sekhar's user avatar
3 votes
2 answers
3k views

Sitecore Dependency Injection - Registering services with the lifetime of a web request

How can I register a service with "PerWebRequest" lifetime using the native Sitecore DI? I can imagine I need to play around the Scoped lifetime and set the default scope to Web Request somehow? Did ...
Volodymyr Hil's user avatar
7 votes
1 answer
1k views

IoC in Helix architicture

I am using Castle.Windsor on my project which based on Helix principle. Where the best place to initialize IoC in Helix? Where I should register container? Foundation/Project layer(Common project or ...
Vlad's user avatar
  • 1,420
8 votes
2 answers
1k views

Dependency Injection for a Sitecore Rule

I've got a Sitecore Rule, based on WhenCondition<T> where T : RuleContext Is there a way to use dependency injection on a sitecore rule? Currently having to use service locator pattern within ...
Ian's user avatar
  • 1,072
9 votes
2 answers
1k views

Sitecore Dependency Injection - register two abstractions to same singleton instance of an implementation

When using the native Sitecore Dependency Injection I have 2 abstrations: IService IExtendedService I want them both to be registered to same singleton instance of a ServiceImplementation How do I ...
Volodymyr Hil's user avatar
5 votes
1 answer
720 views

Can I use automatic dependency injection with computed search fields in Sitecore 8.1?

I am creating a custom computed content search field that has one dependency: ISearchSettings. I'd like it to be injected via constructor: public class CustomField : AbstractComputedIndexField { ...
Dmytro Shevchenko's user avatar
5 votes
2 answers
522 views

Helix and Computed Index Fields with DI

In my solution, I have some Computed Index Fields that I need to add that combine the values of fields from templates that belong to multiple Project-layer modules. I am using DI for initializing my ...
Zachary Kniebel's user avatar
12 votes
2 answers
1k views

Injecting dependencies into a custom WFFM save action

We have a client that is on 8.1u1 and is using WFFM. They want to integrate the data collected on the form into Dynamics CRM, however the OOTB save actions for creating entities in the CRM aren't ...
LonghornTaco's user avatar
  • 2,536
12 votes
3 answers
647 views

Dependency Injection migration path to 8.2

With native support for Dependency Injection in Sitecore 8.2, what is the easiest path for upgrading from previous versions in solutions utilizing a third party DI framework (Castle Windsor, ...
Kasper's user avatar
  • 2,156
39 votes
5 answers
6k views

Best approach for Dependency Injection in Sitecore 8.2

I see a fair few approaches in blog posts for using DI with 8.2, particularly around the registration. Is there an approach which would be recommended - particularly with a Helix compatible ...
Eldblom's user avatar
  • 910
16 votes
1 answer
1k views

SimpleInjector as default DI in Sitecore 8.2

I read this post today about replacing Sitecores 8.2 default DI (https://medium.com/@structuredcode/replacing-the-default-di-container-in-sitecore-8-2-4e65d4956c99), but the example is for Autofac. We ...
Adam Seabridge's user avatar
8 votes
1 answer
722 views

Should I reference Microsoft.Extensions.DependencyInjection in modules I create for Sitecore 8.2+?

So I'm in the process of upgrading various modules to Sitecore 8.2. Among other things this involves getting rid of IoC container project references and getting on board with the Sitecore one. And ...
Mark Cassidy's user avatar
  • 25.3k
7 votes
2 answers
1k views

How to override/replace the default Sitecore Authentication Controller

I upgraded my site from 7.5 to 8.1 and when I try to click on Sitecore logout link I have the following error: Multiple types were found that match the controller named 'Authentication'. ...
Mohammed Syam's user avatar
5 votes
2 answers
505 views

Where can I find the instructions for setting up SOLR without using IOC?

I'm trying to setup an instance of Sitecore 8.2 so I can see what it's going to take to upgrade my site from Sitecore 8.1 to it. I've heard that Sitecore 8.2 can run SOLR natively (without using IOC), ...
Keith VanderVeen's user avatar

1
2