Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
65 views

Sitecore looking for parameterless constructor despite DI working

I'm new to Sitecore. v9.01 I have a class with constructor as below: public Filter(IFilterHelper filterHelper) { _filterHelper = filterHelper; } When I publish the site I get the error that it ...
1
vote
2answers
37 views

How can I pass correct IProviderSearchContext context of my custom index to repository via Dependency Injection?

I have a custom index which has additional teaser title, teaser description, main title and main content fields and the index is resolved based on Sitecore.Context.Database. Eg. master database ...
0
votes
2answers
75 views

Could not create object from service provider - Registering service using Dependency Injection

I have created an ItemNotFoundResolver and injected it after ItemResolver pipeline as follows : public class ItemNotFoundResolver : HttpRequestProcessor { private readonly ISitecoreEntityService ...
2
votes
0answers
65 views

How to inject dependencies in solution that extends Sitecore Reference Storefront

I patched the Initialize Pipeline InitializeControllerFactory processor to point to my new solution InitializeControllerProcessor via: <?xml version="1.0"?> <configuration xmlns:patch="http:/...
0
votes
2answers
320 views

Autofac in Sitecore 9

I have a clean installation of Sitecore 9.0.2 and am trying to hook up Autofac, however I am getting the following exception when trying to load any page on the site / CMS. In the logs: Exception: ...
1
vote
0answers
37 views

Injecting dependencies into custom ServicesApiController without using ServiceLocator

I am injecting a dependency into an custom Api controller I've created that is inheriting from ServicesApiController. I have found that I need to use our service locator class to do this as otherwise ...
1
vote
1answer
396 views

Dependency Injection for Sitecore pipeline processor

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 ...
9
votes
1answer
119 views

Initialize service in pipeline to be available through one httprequest

We're using Sitecore 8.2, habitat. I have a service that I need to use throughout a full HTTP Request. This service should be instantiated once (we use dependancy injection) and then be available ...
0
votes
0answers
122 views

Inconsistent “Service has been disposed” error from Glass.Mapper

Our Sitecore setup had been running just fine for more than a year but during the Christmas break at the end of last year we suddenly had one of our CD servers go down with the following error being ...
0
votes
0answers
81 views

Sitecore 8 can't inject the registered service

I have a Single Sitecore instance with 2 sites. Each of these sites has their own project and solution. For the first project, I used code based configuration for services. For the second project I ...
2
votes
1answer
150 views

Is Pipeline Ref Factory still available?

As described in this article. https://cardinalcore.co.uk/2014/07/02/sitecore-pipelines-commands-using-ioc-containers/ you can use pipeline "ref" and "factory" attributes, to use dependency injection ...
5
votes
1answer
140 views

Getting an instance of BaseCorePipelineManager

In the Sitecore doc Configuring Federated Authentication there are instructions to generate the URL links to initiate Federated Auth -- the lines are: using Sitecore.Pipelines.GetSignInUrlInfo; /* [.....
8
votes
2answers
173 views

Dependency Injection Not Wiring Up Properly When Optimize Code is Selected in Build

Sitecore 8.2u5 Primary Question Why does Optimizing Code cause Dependency Injection to fail? We've used DI on many projects at this point and just had an issue with a recent one. The error ...
1
vote
2answers
198 views

Sitecore Content Search Exception: Entry point was not found

I'm having an issue taking an older version of our site running under Sitecore 7.2 (with some older dll's such as glass mapper) and switching over from Lucene to Solr (6.6.2). I've followed the steps ...
4
votes
0answers
590 views

Ninject activation exception on publish: ILogManager

I started getting a strange error on publish in one our our dev sitecore instances that seems to be coming from some Sitecore.Social.Client piplines. Exception[1]: Ninject.ActivationException ...
1
vote
1answer
188 views

Sitecore.DependencyInjection will not resolve

I'm trying to use dependency injection with the Helix project structure for a sitecore 8.1 project, but I'm having an issue resolving the correct dependencies. The code has been copied from the Helix ...
1
vote
1answer
389 views

Glass Mapper and Microsoft DI

I am using Microsoft DI with Sitecore 8.2 Update 3. I have registered my Glass Items like this: serviceCollection.AddTransient<ISitecoreContext>(provider => new SitecoreContext()); ...
5
votes
0answers
653 views

Sitecore 8.2 Pipeline dependency injection not working [closed]

I have a custom pipeline processor that uses the standard dependency injection. I'm using Sitecore 8.2 update 3. According to this link, I need to set the resolve="true" attribute in my pipeline ...
9
votes
3answers
843 views

Sitecore 8.2 memory leak with autofac DI on load test

We implemented the Autofac to work with Sitecore default DI implementation by following the guide below: https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/...
6
votes
3answers
2k views

How to register Glass Mapper ISitecoreService in my Ioc

Using GlassMapper 4, Sitecore 8.2 update 3 and Microsoft DI How do I register the GlassMapper SitecoreService in my Ioc. It requires a Database and Im not entirely clear on how to get that inside my ...
7
votes
2answers
348 views

IOC (Simple Injector) with EntityService

UPDATED WITH LATEST RESULTS AND QUESTION I've converted everything to pipeline and integrated Simple Injector. As I mentioned, I've never used SI before, and I'm having trouble with the controller ...
4
votes
0answers
158 views

After replacing default DI container Sitecore 8.2 Sitecore ItemService and EntityService stop working

Thanks to Dmytro Shevchenko http://structuredcode.com/replacing-default-di-container-sitecore-8-2/ We are replacing default DI Container with Windsor Castle. All project works perfectly fine, except ...
9
votes
1answer
511 views

Recursive upgradeable lock acquisitions not allowed in this mode exception while accessing Sitecore configuration while initiating the IoC container

When trying to access the Sitecore Configuration Factory to read a setting while configuring services in the IoC container the below exception is thrown. public class ServicesConfigurator : ...
1
vote
1answer
77 views

Custom controller being overwritten by IoC

I have a simple Sitecore controller that returns an list of items from Sitecore. It's used it in a custom SPEAK UI page. This works fine in my local dev environment but when I deploy it into an ...
9
votes
1answer
2k views

Castle Windsor on Sitecore 8.2 using Glass Mapper v4

I'm trying to setup Castle Windsor for Dependency Injection in Sitecore 8.2 Solution which is using Glass Mapper v4. As noted, Castle Windsor is no longer part of Glass Mapper, and thus not included. ...
5
votes
1answer
153 views

Singleton search context for search api

Typical usage of search api uses a using statement to dispose of the search context. using (var context = ContentSearchManager.GetIndex(_indexName).CreateSearchContext()) { var hits = context....
7
votes
6answers
1k 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 ...
7
votes
2answers
9k views

No parameterless constructor defined for this object after upgrade to sitecore8.2

We have upgraded our platform to sitecore8.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. ...
3
votes
2answers
1k 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 ...
7
votes
1answer
897 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 ...
8
votes
2answers
443 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 ...
8
votes
2answers
759 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 ...
4
votes
1answer
259 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 { ...
5
votes
2answers
300 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 ...
12
votes
2answers
759 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 ...
11
votes
3answers
409 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, ...
38
votes
5answers
4k 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 ...
16
votes
1answer
964 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 ...
8
votes
1answer
558 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 ...
7
votes
2answers
566 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'. ...
5
votes
2answers
286 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), ...